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,890 points

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
• 13,250 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, 2019 in Python by Waseem
• 4,540 points
+2 votes
11 answers
+1 vote
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
+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
• 69,030 points

edited Aug 8, 2018 by Omkar 4,522 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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,466 views
0 votes
0 answers
0 votes
2 answers

Equivalent of a?b:c in Python

result = "F" if(isfemale_bit) else "M" print(result) Try this ...READ MORE

answered Dec 14, 2019 in Python by Manel
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, 2019 in Python by SDeb
• 13,250 points