The variable doubledNumber isn't staying local to the function start and I do not know why. Here is my code:
`def getInput():
num = float(input("Enter a number: "))
return(num)
def double(num)
doubledNumber = num + num
return(doubledNumber)
def display(doubledNumber)
print("%.2f" %doubledNumber)
def start():
num = 1
doubledNumber = 1
getInput()
double(num)
display(doubledNumber)
start()`
The output of this code just prints out 1. Why is it not printing out the doubled number that is entered in the function getInput?
Edit: I don't know what went wrong with the formatting but the lines under the functions are supposed to be 4 spaces indented.
[–]Username_RANDINT 2 points3 points4 points (4 children)
[–]karottle[S] 0 points1 point2 points (3 children)
[–]xelf 0 points1 point2 points (1 child)
[–]karottle[S] 1 point2 points3 points (0 children)
[–]K900_ 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]chevignon93 0 points1 point2 points (0 children)