'IndexError: tuple index out of range' whith str.format
2 answers
You have created two format fields:
print('script executed in {time}{1:.2f} seconds'.format(time=elapsed_time))
# ^1 ^2
but gave only one argument str.format
:
print('script executed in {time}{1:.2f} seconds'.format(time=elapsed_time))
# ^1
You need the number of format fields to match the number of arguments:
print('script executed in {time:.2f} seconds'.format(time=elapsed_time))
+7
source to share