-2
我在第2行收到錯誤,說我有一個unboundLocal錯誤。任何人都可以向我解釋如何解決這個問題?UnboundLocalError:分配前引用的局部變量'number1'
def main():
number1=getNumber1(number1)
number2=getNumber2(number2)
userIntro=''
printInfo=0.0
answer=0.0
#intro module welcomes the user
def userIntro():
print('hello welcome to my maximum value calculator')
print('today we will evaluate two number and display the greater one')
#this module gets the value of number1
def getNumber1(number1):
number1=print(input('Enter the value of number1'))
return (getNumber1)
#this module gets the value of number2
def getnumber2(number2):
number2=print(input('Enter the value of number2'))
return (getNumber2)
#this module takes the values of number1,number2 and displays the greater value
def printInfo(number1,number2,answer):
answer=max(number1,number2)
return (answer)
main()
'數字1 = getNumber1(數量1) NUMBER2 = getNumber2(數字2)'你想創造和傳遞變量該功能在同一時間? – Nf4r
你預計主要的前兩行是做什麼的?想想你在那裏做什麼,你的錯誤將變得清晰。此外,您的代碼還有其他錯誤。 –