[Tutor] A simple "if" and "elif" problem
Emile van Sebille
emile at fenx.com
Sat May 5 20:08:14 CEST 2012
On 5/5/2012 11:01 AM Santosh Kumar said...
> I am reading the documentation and I'm in the section 4.1. Let me
> write it down here:
You'll need to peek ahead to section 8 Errors and Exceptions.
Try and see if that doesn't get you going.
Emile
>
>>>> x = int(input("Please enter an integer: "))
> Please enter an integer: 42
>>>> if x< 0:
> ... x = 0
> ... print('Negative changed to zero')
> ... elif x == 0:
> ... print('Zero')
> ... elif x == 1:
> ... print('Single')
> ... else:
> ... print('More')
> ...
> More
>
> Now I want to add a filter in this script, I want when a user enter a
> string here it give a warning "Please enter a number like 0 or 2".
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list