[Tutor] Why does my code show this?

Alan G alan.gauld at freenet.co.uk
Mon Jul 11 01:03:28 CEST 2005


>  cal_opt = int(raw_input("What option would you like: "))

Here you get the input and convert it to a number (int() )
which is fine.

>  if cal_opt == "1":

But here you compare it to a string (see the quotes).

So either remove the convertion to int() around raw_input or 
remove the quotes around the values. The things you compare 
must be the same type.

>  That's not an option. Try again.
>  Option: 3
>  3*4
>  12

I'm not sure how the multiplication appeared though! 

Alan G.


More information about the Tutor mailing list