如何给一个变量分配一个新的数字,预先给定相同的数字?

2024-09-30 14:28:16 发布

您现在位置:Python中文网/ 问答频道 /正文

如果给定的数字小于2,它会要求使用递归重新输入数字

我首先给出了2,然后在递归之后,我给出了3,但是输出仍然是2

如何输出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())

Tags: thenumberinputifdef数字intwe