Python Question

Split() that recognizes the types

I have a phrase like this:

a='Hello I have 4 ducks'

and I apply
to this, so I now I have

>>> a.split()

the problem is that every
is a string, but I need the program to recognize that the 4 is an integer. I need this to know which position the first integer is in, so I do this:

if(isinstance(a[i], float) or isinstance(a[i], int)):

but every
is a string.

Can I do something that makes my program recognize the integers inside this list?

Answer Source
demo_list = ['Hello','I','have','4','ducks']
for temp in demo_list:
    print temp
    if temp.isdigit():
        print "This is digit"
        print "It is present at location - ", i

Output: This is digit.

It is present at location - 3

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download