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,910 points
996 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
• 13,300 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
477 views
+1 vote
12 answers
+1 vote
2 answers

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

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

answered Oct 28, 2020 in Python by Anurag
12,374 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
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 15, 2019 in Python by Manel
4,181 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, 2019 in Python by SDeb
• 13,300 points
1,045 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP