I have a little question about variables. My main language is Java (and I'm learning Python) so, I have a problem calling a variable in a function, it doesn't refresh its new value:
# Values
global e1x, e1y, e1c, e2x, e2y, e2c, altx, alty, x, y
def getValues():
print("Taking Ax + By = C:")
e1x = float(input("Value of x in first equation: "))
#...
if(confirm()): # A function I ommited 'cause its irrelevant
return e1x, e1y, e1c, e2x, e2y, e2c
else:
getValues()
def calculateValues():
# Stuff with variables
# MAIN
getValues()
calculateValues()
I tried to write it without the global, tried to use the self word but, It doesn't work. (Using Python 3)
ERROR:
Traceback (most recent call last):
File "E002_GaussSeidel.py", line 41, in <module>
calculateValues()
File "E002_GaussSeidel.py", line 34, in calculateValues
print(str(e1x))
NameError: name 'e1x' is not defined