I am making a program that requires an input loop that reads from a previous list and uses that data in the user prompt. I can't find how to make the loop display the next list item on each loop.
I have tried different things but haven't got it to work. I have it set now as just itemName0 but want to have it go up till the loop ends (itemName1
, itemName2
etc...)
Item names (itemName0
,itemName2
,etc...)
for x in range(itemNum):
globals()['itemName%s' % x] =input("Enter item name: ")
#Item Values (itemValue0,itemValue1,...)
for x in range(itemNum):
globals()['itemValue%s' % x] =float(input("Enter value for "+(itemName0)+(": ")))
I'm hoping to get to this:
Enter item name: Pants
Enter item name: Shirts
Enter item name: socks
Enter value for Pants:
Enter value for Shirts:
Enter value for socks:
I need the loop to run for however the length of the user inputs as itemNum
but update the items for the names.