#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in 
#Python by Madhavan Mukund, Chennai Mathematical Insti
tute

while(True):  
  try:
    userdata = input(“Enter a number: “)
    usernum = int(userdata)
  except ValueError:
    print(“Not a number. Try again”)
  except NameError:
    pass
  else:
    break  

Source link

Use pass for an empty block

Leave a Reply

Your email address will not be published. Required fields are marked *