So, I'm kind of new to Python, and I'm trying to make a small command line menu system with lists, using the following code:
menu = ["item1", "item2", "item3", "item4"]
i = 0
for item in menu2:
print(str(i) + str(menu[item]))
i = i + 1
But whenever I run that code, I'm thrown the following error:
TypeError: list indices must be integers, not str
Can anyone tell me why this is happening or how to fix it? I've tried most anything I can think of.
Thanks in advance!
remove str also not needed menu. print statement should be like below.
print(i + item)