这是我试图获取场地价格的代码:
# number of people
header = "Number of People"
people = ["10-25", "26-50", "51-100", "101-500", "501-1000", "1000+"]
button = buttonbox("around how many people will attend",title= header,choices=people)
# choosing the venue
if button == people[0]:
button = "you chose '10-25'"
header = "Recommended Venues"
venueZero = ["your home, $0.00", "small garden, $20.00", "planetarium, $30.00"]
button = buttonbox("Choose a venue",title= header,choices=venueZero)
这是我用来尝试为venuePrice
分配值的代码:
if button == people[0] and button == venueZero[0]:
venuePrice=4444
print venuePrice
但是,当我打印venuePrice
时,它表示没有定义。
答案 0 :(得分:0)
button
无法同时与people[0]
和venueZero[0]
相等,因此if语句中的条件永远不会被满足,因此venuePrice
赢了&# 39;设置。
您可以为第二个选择使用不同的变量名称:
# number of people
header = "Number of People"
people = ["10-25", "26-50", "51-100", "101-500", "501-1000", "1000+"]
button = buttonbox("around how many people will attend",title= header,choices=people)
# choosing the venue
if button == people[0]:
button = "you chose '10-25'" # I don't understand the purpose of this statement but I'm not sure if you need it for anything so I'll leave it here.
header = "Recommended Venues"
venueZero = ["your home, $0.00", "small garden, $20.00", "planetarium, $30.00"]
button2 = buttonbox("Choose a venue",title= header,choices=venueZero) # Changed from button to button2
然后更改if语句:
if button == people[0] and button2 == venueZero[0]:
venuePrice=4444
print venuePrice