Conversion of string to integer

Adam adamgarstang at googlemail.com
Mon Jan 29 14:35:34 EST 2007



On Jan 29, 1:55 pm, "jupiter" <anil.jupit... at gmail.com> wrote:
> Hi guys,
>
> I have a problem. I have a list which contains strings and numeric.
> What I want is to compare them in loop, ignore string and create
> another list of numeric values.


You can iterate over the list and use the type() function to work out 
what each entry and choose what to do with it.

type() works like so:
###Code###
>>> a = ["test", 1.25, "test2"]
>>> if type(a[2]) == str:
	print "a string"


a string
>>>
###End Code###

Adam




More information about the Python-list mailing list