Im trying to use a counter and an list to input a size then store it, but im hit with
list assignment index out of range
even thou range is set to the value of counter
while counter < P_Ammount:
P_Size[counter] = input("Enter A Size S= Small M= Meduim L= Large ")
if P_Size[counter] == "S" or P_Size[counter] == "s": # both types of valadation for Lower and upper case
P_Size_Cost[counter] = 3.25 #Setting Price To List for Small
if P_Size[counter] == "M" or P_Size[counter] == "m":
P_Size_Cost[counter] = 5.50 #Setting Price To List for Meduim
if P_Size[counter] == "L" or P_Size[counter] == "l":
P_Size_Cost[counter] = 7.15 #Setting Price To List for Large
counter + 1
counter = 0
P_Size = []
P_Size_Cost = dict()
while counter < P_Ammount:
size = input("Enter A Size S= Small M= Meduim L= Large ")
P_Size.append(size)
if P_Size[counter] == "S" or P_Size[counter] == "s": # both types of valadation for Lower and upper case
P_Size_Cost[counter] = 3.25 #Setting Price To List for Small
if P_Size[counter] == "M" or P_Size[counter] == "m":
P_Size_Cost[counter] = 5.50 #Setting Price To List for Meduim
if P_Size[counter] == "L" or P_Size[counter] == "l":
P_Size_Cost[counter] = 7.15 #Setting Price To List for Large
counter = counter + 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.