EpythonProject1venvScriptspythonexe EpythonProject1mainpy Traceback most recent call last File EpythonProject1mainpy line 7 in module total=sum12 ^^^^^^^^ File EpythonProject1mainpy line
The error message suggests that there is a NameError in your code. Specifically, the variable 'total' is not defined. This error occurs when you try to use a variable that has not been assigned a value.
To fix this issue, you need to define the 'total' variable before using it. Here's an example of how you can fix the code:
def sum(a, b):
total = a + b
return total
result = sum(1, 2)
print(result)
In this example, the 'total' variable is defined inside the 'sum' function and then returned. The returned value is then assigned to the 'result' variable and finally printed
原文地址: https://www.cveoy.top/t/topic/ioC3 著作权归作者所有。请勿转载和采集!