Im doing a string formatting for a python program however, i am getting an error “not enough arguments for format string”.
my line of portion of code is
a[i][j] = input("college %d %s" %(j+1) %d[i])
can somebody point out my mistake? as i can’t figure out on my own
You should be saying
This is because the % string formatting operator expects a single argument, so if you want multiple formatters, you need to pass a tuple. So I can’t say
I instead must say
If you’re using Python 2.6 or later, you also have the option of using the format method, e.g.
And if you’re using Python 2.7 or later, you can omit the index values, and simply say