計算機のプログラミングの中のresultという変数が上手く機能しません
僕はpython 3で簡単な計算が出来て10個までの計算結果をリストに保存出来てかつ10個目以降の答えをまた最初から保存できるプログラミングを作ったのですが何度プログラミングを組みなおしても
name 'result' is not defined
とresultの変数が定義されていないというエラーしか出ませんでした。「どこかresultを定義し忘れたかな?」と思いコードを何度か確認しましたが特に定義のし忘れやモジュールの中に変数のミスは見当たりませんでした。
このコードの中でresultの変数を定義をし忘れている個所あるいは変数のミスを教えてください
answerlist = [0,0,0,0,0,0,0,0,0,0]
counter = 1
def decideprocess():
global decision
decision = str(input("Enter + for adding, - for subtracting, * for multiply, / for deviding, and 'all' for see what all calculation results so far. :"))
def processes(result):
global decision
global counter
decision = decideprocess()
while decision == "+" or decision == "-" or decision == "*" or decision == "/" or decision == "all":
if decision == "+":
result = addition()
decideprocess()
return counter
elif decision == "-":
result = subtraction()
decideprocess()
return counter
elif decision == "*":
result = multiplecation()
decideprocess()
return counter
elif decision == "/":
result = devision()
decideprocess()
return counter
elif decision == "all":
for a in range(0,len(answerlist)):
print(answerlist[a])
decideprocess()
else :
showallresult()
return result
def addition():
global counter
a = float(input("Enter any number. :"))
b = float(input("Enter any number. :"))
result = a + b
print(result)
counter = counter + 1
assignment(result)
return(result)
def subtraction():
global counter
a = float(input("Enter any number. :"))
b = float(input("Enter any number. :"))
result = a - b
print(result)
counter = counter + 1
assignment(result)
return result
def multiplecation():
global counter
a = float(input("Enter any number. :"))
b = float(input("Enter any number. :"))
result = a * b
print(result)
counter = counter + 1
assignment(result)
return result
def devision():
global counter
a = float(input("Enter any number. :"))
b = float(input("Enter any number. :"))
result = a / b
print(result)
counter = counter + 1
assignment(result)
return result
def assignment(result):
global counter
while counter < 10:
assignmentanswer(result)
if counter >= 10:
changecountervalue()
assignmentanswerover10(result ,newcounter)
return result, newcounter
def assignmentanswer(result):
global counter
answerlist[counter] = result
return result
def changecountervalue():
global counter
counter10 = int(counter/10)
newcounter = (counter10*10) - counter
return newcounter
def assignmentanswerover10(result, newcounter):
answerlist[newcounter] = result
return result, newcounter
def showallresult():
for a in range(0,len(answerlist)):
print(answerlist[a])
def calculator(result):
global counter
global decision
processes(result)
return result
def CALCULATOR(result):
calculator(result)
return result
CALCULATOR(result)