mercredi 20 janvier 2016

How do i print an output if the value entered is not an integer

I am trying to do two things here.

I want to print "value entered is not a valid age" if the input is not a number in this code:

age = float(input (' enter your age:  '))
if 0 <age < 16:
    print "too early for you to drive"
if  120 >= age >= 95:
    print 'Sorry; you cant risk driving'
if age <= 0:
    print 'Sorry,' ,age, 'is not a valid age'
if age > 120: 
    print 'There is no way you are this old. If so, what is your secret?'
if 95 > age >= 16:
    print 'You are good to drive!'

Also, how can I repeat this program once it is done?

Aucun commentaire:

Enregistrer un commentaire