我正在嘗試創建一個RPG,在遊戲中玩家可以命名他們的角色。我遇到了一些麻煩,說它的名字是未定義的。我理解Python 2中的raw_input,這不是問題,我已經測試過,如果將'input'更改爲'raw_input',它根本不起作用,它只會結束程序。我想知道是否有人能幫我解決這個問題。如何輸入玩家名稱?
下面是我的代碼(我把我的名字從信貸對隱私的目的):
import random
PN = 0
Hit = 0
health = 50
level = 0
EXP = 0
nameless_variable_1 = 0
print("Hello, and welcome to my creation!")
print("To begin type 1")
print("to see credits type 2")
print("to quit go to the X button in the corner and click it")
print("to continue type what you want to do and hit enter on your keyboard.")
nameless_variable_1 = input("what is your choice??????")
if nameless_variable_1 == 2:
print("................. The entire game")
print("do you want to play the game now?")
print("if you do press one and then hit enter")
nameless_variable_1 = input(" ")
if nameless_variable_1 == 1:
PN = input("what is your character Name?")
print("it is the year 2019 and you are trying to assasinate an important person")
print("if you fail at this task, you can and probably will die.")
有什麼問題嗎? – MMF
我正在尋求我的問題的幫助。 –
你使用的是Python 2還是Python 3? – ImportanceOfBeingErnest