Hi everyone,

I am new to python and have a noob question.

Is it generally better to use try/except/else statements or if/elif/else?
Or, is there a time and place for each?

For a simple example, assume I want a user to enter a number

1) try:
       number = float(input('enter a number: ')
   except ValueError:
       print('enter a number.')
   else:
       print('you entered a number')

*OR*
*
*
2) number = float(input('enter a number: ')
    if number >=0 or < 0:
        print('you entered a number')
    else:
         print('enter a number.')

Thanks for the help.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to