Im beginner just wanted to know the error ,unless its equal to 2 the loops run,but when i enter the exact number which is 2 ,the loop does'nt end

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