How to make the function to prompt the user repeatedly till he enters a correct no which is in the tuple?

def ck_no(prompt):
while True:
    try:
        
        lst = (2,3,4)
        if prompt not in lst:
            print("not in list")
            raise ValueError
        else:
            print("In the List")
    except ValueError as e:
        print(e)
        return

ck_no(int(input(print("Enter a No: "))))

Enter a No: 

None

After calling the function it prompts the user to enter the no. But it prints none. Beside none if enter the no it accepts and the pgm continues. How to correct this none.

I want to prompt the user again and again to enter different nos. How to do this?

1 Like

Set the initial answer to None and while the answer is not in the tuple prompt for input.

1 Like