If you specifically need an int or float, you could try "is not int" or "is not float":
user_input = ''
while user_input is not int:
try:
user_input = int(input('Enter a number: '))
break
except ValueError:
print('Please enter a valid number: ')
print('You entered {}'.format(a))
If you only need to work with ints, then the most elegant solution I've seen is the ".isdigit()" method:
a = ''
while a.isdigit() == False:
a = input('Enter a number: ')
print('You entered {}'.format(a))