0
我是初學者編碼者,我有這個遊戲,但我的問題是,在我的遊戲中,用戶有點可以花在戰鬥中。並且它應根據您花費的多少更新點變量。我的全局變量的答案?
global Points
Points = int(100)
def Combat():
print('how much points would you spend(higher points = higher chance of winning')
a9 = int(input('>'))
Points = int(Points)- int(a9)
global Points
print('You have ',Points,' points')
但由於某些原因,它不會改變全局點變量,任何答案? 這是否有答案? 還是未解決?
給出的答案是絕對正確的,將完全解決您的範圍問題!我會推薦研究Python的面向對象編程,以便充分理解是什麼讓語言變得如此強大!類是避免範圍問題並大大減少重新輸入的好方法!祝你好運,祝好! – TheLazyScripter