i run this formating code print("%15s%.2f"%((heights[j])),end="") but i have this error what is the wrong here ??
TypeError: not enough arguments for format string
i run this formating code print("%15s%.2f"%((heights[j])),end="") but i have this error what is the wrong here ??
TypeError: not enough arguments for format string
What does your heights looks like?
Here is a working example
heights = [("test",3.14)]
print("%15s%.2f"%((heights[0])),end="")
So heights must be a list of tuples or lists with 2 elements.
the first % formats the first value into the string and the second % formats the second value. The problem is you only have one value to format into the string (unless heights[j] is a list or tuple.
if you want heights[j to be formatted in both places, i suggest doing something like this:
print("{0}15s{0}.2f".format(heights[j]), end="")
this will replace every {0} in the string with the first argument passed to format()