[英]How To Fix "list assignment index out of range"
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.