[Tutor] help with integers

Alan Gauld alan.gauld at btinternet.com
Wed Sep 15 02:23:05 CEST 2010


"Ciera Jones" <cjo1555 at gmail.com> wrote

> When I enter myvar= raw_input ("Please excuse a number of movies: ")
> and I try and convert it to an integer it gives me an error message.
> I put in:
> movietotal=  int("myvar")* 3 and I get an error message

Don't put quotes around the variable name.
Python is trying to convert the string "myvar" to an int, which it 
can't.

BTW When posting it is best to send the code plus entire error 
message,
it greatly helps us debug the problem.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list