def number(num):
while(num != 2):
num = input(‘enter again:’)
else:
print(num)
input() returns a string, so if you type 2, num becomes ‘2’ (str) and not 2 (int)
you could convert the result to an int with int()
like this
num = int(input(‘enter again:’))
it will raise an exception if you enter something not convertible to an int