I am new to python and trying to learn the basic
just learned how to format string today and couldn't figure out what is wrong with this line of codes
data = ["Zac", "poor fella", 100]
format_string = "%s is a %s, his bank account has $%s."
print(format_string % data)
my goal is trying to print out "John is a poor fella, his bank account has $100."
But when I run it it came back with "Python TypeError: not enough arguments for format string"
Please let me know what I did wrong, thanks!
I tried putting parentheses in between format_string and data
You have to use
tupleinstead oflistand use%to format the string:Result: Zac is a poor fella, his bank account has $100.
You could use modern f-string formatting: