Computer Science Canada Need help with my if / elsif ! |
Author: | m84uily [ Fri Jan 07, 2011 4:07 am ] | ||
Post subject: | Need help with my if / elsif ! | ||
I'm just starting out with Python and I can't figure out why I'm getting a syntax error on my elif. Help would be very much appreciated, thanks in advance.
|
Author: | m84uily [ Fri Jan 07, 2011 4:36 am ] | ||
Post subject: | Re: Need help with my if / elsif ! | ||
Did this instead and it works fine, decided to just give up on the function xD. |
Author: | rdrake [ Fri Jan 07, 2011 6:20 am ] | ||||||
Post subject: | Re: Need help with my if / elsif ! | ||||||
It wasn't your elif, it was what you had inside that was causing issues. You cannot do this.
Also lose the input(), it's dangerous. Just use raw_input() and treat the potential choices as strings. Just because I can:
Though it's not quite as forgiving as yours is, it's easy to fix if you really want.
|
Author: | m84uily [ Fri Jan 07, 2011 12:06 pm ] | ||||||
Post subject: | Re: Need help with my if / elsif ! | ||||||
rdrake @ Fri Jan 07, 2011 6:20 am wrote: It wasn't your elif, it was what you had inside that was causing issues. You cannot do this.
Also lose the input(), it's dangerous. Just use raw_input() and treat the potential choices as strings. Just because I can:
Though it's not quite as forgiving as yours is, it's easy to fix if you really want.
Thanks a lot! Why is input() dangerous, though? |
Author: | DemonWasp [ Fri Jan 07, 2011 1:36 pm ] |
Post subject: | RE:Need help with my if / elsif ! |
The documentation on input() is here: http://docs.python.org/library/functions.html#input The reason it's dangerous is that it lets you enter scripts. The user could input any Python expression, which can be pretty well whatever they want. I'm sure someone could figure out a relatively easy way to use this to delete files, download something from the internet and run it, or whatever else. |