Print C format in Python

0 votes

Hi, I am a beginner in Python programming and I want to know how to print with the C format in Python with a list of parameters such as :

agrs = [1,2,3,"hello world"]
string = "This is a test %d, %d, %d, %s"


The Output should be:
This is a test 1, 2, 3, hello world
Sep 18, 2018 in Python by ana1504.k
• 7,430 points
30 views

1 answer to this question.

0 votes

For printf- style formatting and special case Tuple for formatting multiple value, string overloads the modulus (%) operator. the simple way to do it is by converting list to tuple

answered Sep 18, 2018 by SDeb
• 12,280 points

Related Questions In Python

0 votes
0 answers

How can you print the date in a regular format in python?

Is there a module or package in ...READ MORE

Jun 18 in Python by Waseem
• 3,400 points
8 views
+2 votes
11 answers

How to print array/ list without brackets in python?

name=["a","b","c"] print (', '.join(name)) It will simply take all ...READ MORE

answered Apr 18, 2018 in Python by aayushi
• 750 points
16,202 views
0 votes
1 answer

How to print first character of each word in upper case of a string in Python

You can use split() using space as ...READ MORE

answered Jun 1, 2018 in Python by george
• 200 points
1,369 views
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 67,120 points

edited Aug 8, 2018 by Omkar 382 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 124 views
0 votes
1 answer

Equivalent of a?b:c in Python

In Python 2.5, you can use ternary ...READ MORE

answered Jan 7 in Python by SDeb
• 12,280 points
14 views
0 votes
1 answer

Why do variables have bigger scopes in Python than in C?

Only functions, modules, and the bodies of ...READ MORE

answered Jul 2 in Python by SDeb
• 12,280 points
9 views