import random
import time
def set_balance():
print("Welcome to balance manager")
print()
print("1, Demo mode (10,000 play chips)")
print("2, Real mode (PayPal, BTC deposit)")
print()
choice = int(input("Please enter your selection: "))
if choice == 1:
global balance
balance = 10000
demomode = 1
elif choice == 2:
global balance
balance = int(input("\nEnter the ammount to pay in £"))
def spin_wheel():
print("\n\n\n\n\n\n\n\nLETS PLAY ROULETTE, YOUR BANK IS, £", balance)
print()
print("Red, 1")
print("Black, 2")
print("Please select your colour from the menu below")
choice = int(input("\nOption selected "))
내가 여기서 잘못 했습니까?UnboundLocalError : 할당 전에 참조 된 'balance'로컬 변수
은 당신이 당신의 코드를 리팩토링 반환 할 수 있습니다 전역 변수, 또는 적어도'global' 키워드에 대한 필요성을 제거하십시오. –
@JustinEthier, 잘 기술적으로 함수는 전역 변수입니다 :) –
@gnibbler - 당신은 실제로나요? - http://tirania.org/blog/archive/2011/Feb-17.html –