我正在开发一个基于文本的游戏,该游戏基于用户的回答问题,但是当用户输入导致else:
的无效答案时,我该如何再次提出问题并从中寻求答案再次成为用户?
这是我苦苦挣扎的代码:
if pc_offer == "1":
money =- 6000
quality =+ 9
mp
elif pc_offer == "0":
sleep(1)
print("""
Okay, Choose the perfectly priced set up you want:
1. $2000
2. $3000
3. $4000
4. $5000
5. $6000
6. $7000
7. $8000
""")
choose_pc = input("What one? Press the number corrosponding to it.")
if choose_pc == "1":
money =- 2000
quality =+ 5
mp
elif choose_pc == "2":
money =- 3000
quality =+ 6
mp
elif choose_pc == "3":
money =- 4000
quality =+ 7
mp
elif choose_pc == "4":
money =- 5000
quality =+ 8
mp
elif choose_pc == "5":
money =- 6000
quality =+ 9
mp
elif choose_pc == "6":
money =- 7000
quality =+ 10
mp
elif choose_pc == "7":
money =- 8000
quality =+ 11
mp
else:
#Struggle is here
else:
#Struggle is here
变量money
,quality
,mp
和其他变量无关,仅供参考,因此您知道我遇到的问题。
我检查了其他多个类似问题,但没有找到答案。
由于goto
在python中也不存在,因此我不能简单地仅使用goto
。
我有办法再次问问题并再次回答吗?