How to fix TypeError: not enough arguments for format string in Python

3 Answers

0 votes
a = 4
b = 7
c = 9

# TypeError: not enough arguments for format string
# s = "a = %s b = %s c = %s" % a, b ,c

s = "a = %s b = %s c = %s" % (a, b ,c)

print(s)




'''
run:

a = 4 b = 7 c = 9

'''

 



answered Jan 31, 2022 by avibootz
0 votes
a = 4
b = 7
c = 9

# TypeError: not enough arguments for format string
# s = "a = %s b = %s c = %s" % a, b ,c

s = "a = {0} b = {1} c = {2}".format(a, b, c)

print(s)




'''
run:

a = 4 b = 7 c = 9

'''

 



answered Jan 31, 2022 by avibootz
0 votes
a = 4
b = 7
c = 9

# TypeError: not enough arguments for format string
# s = "a = %s b = %s c = %s" % a, b ,c

s = f"a = {a} b = {b} c = {c}"

print(s)




'''
run:

a = 4 b = 7 c = 9

'''

 



answered Jan 31, 2022 by avibootz

Related questions

...