我有一个来自我的班级属性的电影标题和时间列表。我已经显示了这个列表:
for i in range(0, len(films)):
print(i, films[i].title, films[i].time)
这给了我一个标题的数量和时间列表。
现在我想获取标题中的任何项目,以便我可以根据座位数的选择进行计算。
我试过这个:
i = int(input("Please select from our listings :"))
while i <= films[i].title:
i = input("Please select from our listings :")
if i in films[i].title:
print("You have selected film: ",films[i].title)
print("Regular seat: ", choice[regular], "\nVip Seat: ", choice[vip], "\nDiamond Seat: ", choice[diamond], "\nPlatinum Seat: ", choice[platinum], "\nDisability Regular Seat: ", disabilityRegular, "\nDisability Vip Seat: ", disabilityVip, "\nDisability Diamond Seat", disabilityDiamond, "\nDisability Platinum Seat", disabilityPlatinum )
seatType = input("\nSelect your seat from these list: ")
seating = int(input("How many seats: "))
if seating == items in choice:
total = seating*altogether[seatType]
print(total)
运行时显示如下:(注意列表从 0 开始):
29 End of Watch 20:00
30 Gremlins 19:30
31 The Twilight Saga: Breaking Dawn part 2 20:00
Please select from our listings :6
Please select from our listings :4
Traceback (most recent call last):
File "C:/Python32/cin.py", line 91, in <module>
if i in films[i].title:
TypeError: 'in <string>' requires string as left operand, not int