Reputation: 25
How can I make the final value of the variable be the addition of the two user inputs?
def value():
amt = int(input("enter value: "))
def go_again():
again = input("DO you want to go again(y/n)")
if again == "y":
value()
else:
exit()
value()
again()
(This is a shorter code but similar to what I am working on.)
Upvotes: 1
Views: 495
Reputation: 388
Just embed value
function in go_again
and run it in while
loop:
def value():
return int(input("enter value: "))
def go_again():
val = value()
while input("DO you want to go again(y/n)") == "y":
val += value()
exit()
go_again()
Upvotes: 1