Newbie Question

Chris... sca at isogmbh.de
Wed Sep 22 06:27:48 EDT 1999


Dinesh Silva wrote:

> I have a main function with the lines:-
>
>         q1 = raw_input('Enter a number')
>         cont(q1) # Cont is another function.
>
> Cont is a function which returns a number depending depending on the
> user input.
> However it doesn't work because I think that q1 is a string not an
> integer.

right

> Can someone tell me if this is true and if so, how to convert
> the string into an integer. I've tried the atoi function but keep
> getting errors. If the atoi function is the right one to use, could
> someone give an example on how to use it.

I've never heard of an 'atoi' function, but there exists 'int()' that
converts its argument (string or number) to a plain integer.  There also
exist more conversion functions, see the Python Library Reference, section
2.3 (Built-in Functions).

bye
  Chris...





More information about the Python-list mailing list