我想知道为什么我的值“player_action_input”没有得到更新。 值保持为0.我知道我可以使用(player_action_input)而不是(* info)但我想尝试学习如何使用*更新值。 ###如果我运行这个,我得到2个结果。
player_action_input = 0
info = [player_action_input]
def player_action(*info):
while True:
try:
player_action_input = int(input("Enter 0 to stay, 1 to go Up, or 2 to go Down: "))
except ValueError:
print("You have entered an incorrect number, please try again")
continue
if player_action_input == 0:
ready_speech(*info)
if player_action_input == 1:
player_action_input = player_action_input + 1
print ("Thank You, you chose to go up")
count(*info)
if player_action_input == 2:
player_action_input = player_action_input + 2
print ("Thank You, you chose to go down")
count(*info)
else:
print ("You have entered an incorrect number, please try again")
continue
break
def count(*info):
print (player_action_input)
player_action(*info)