[英]is the while true in the correct place? also how do i get the user to prompt the user to add something and then to display it in the while loop?
print('Welcome to Loot Box Simulator!')
gems = 0
boxes = 0
boxes_opened = 0
gem_cost = 19.95
gem_amount = 550
box_cost = 100
while True :
print ('You have',gem_amount, 'gems and', boxes, 'Loot boxes.')
print ('Choose from the following options:')
print ('1) Buy gems', gem_amount, 'gems for just', gem_cost)
print ('2) Buy loot box (costs', box_cost, 'gems)')
print ('3) Open loot box')
print('4) View statistics')
print('5) Quit')
break
我的目标是打印这 5 个问题,然后提示用户 select 5 个问题之一。如果用户选择 1,那么将添加 550 个宝石,打印会改变。 我怎么能做到以上? 我是一个初学者,所以如果你能展示一下可以帮助我理解的变化。 谢谢你
打印出所有这些说明后,您可以尝试跟进:
while True :
print ('You have',gem_amount, 'gems and', boxes, 'Loot boxes.')
print ('Choose from the following options:')
print ('1) Buy gems', gem_amount, 'gems for just', gem_cost)
print ('2) Buy loot box (costs', box_cost, 'gems)')
print ('3) Open loot box')
print('4) View statistics')
print('5) Quit')
users_choice = input("What do you do? (Press the respective number)")
if users_choice == "5":
break
else:
# do whatever you need to do depending on the choice
也许您还想考虑将您的活动捆绑到函数中,然后您可以根据用户的输入/交互调用这些函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.