Typecasting

bblochl bblochl2 at compuserve.de
Mon Feb 23 07:29:22 EST 2004


Hi Everybody,

Can you guide me to convert string into Int datatype?
(i.e. How can we convert string into int? like '555' into 555)

Thanks in advance.

~Rajesh


One possible answer:
Simply use int(). For insdtance:
>>> x="555"
>>> x
'555'
>>> x=int(x)
>>> x
555
Or an application to convert a string input:
>>> x=int(raw_input("Type a number: "))
>>> x
555






More information about the Python-list mailing list