kindacoder
kindacoder

Reputation: 15

How to assign a new number to a variable, given the same number in advance?

If the given number is less than the 2, it asks to reenter the number by using recursion.

I've first given 2 and then after recursion, I gave 3, but the output is still 2.

How to output 3?

def inexpno():
    exp = int(input("Enter the Experiment n.o : "))  # Takes a exp number
    if exp<=2:  # Enter your completed experiment here
        print("It is completed Correction for both Record and Observation\n\n")
        print("Do you want to select another experiment")
        we = input("")
        if we == "yes" or we == "YES":
            inexpno()                              #  TO CHANGE
        else:
            exit()
    return exp


print(inexpno())

Upvotes: 0

Views: 49

Answers (2)

Akaisteph7
Akaisteph7

Reputation: 6506

Just change your recursive line to

return inexpno()   

Upvotes: 1

wjandrea
wjandrea

Reputation: 33032

Currently you don't save the return value from inexpno() in the recursive call on line 8. You simply need to save it as exp:

exp = inexpno()

Upvotes: 1

Related Questions