I'm wracking my brain with this. I need to iterate through a nested list (a list of lists, so only one level of sublist) to check if an entry is a positive or negative integer. If it is, I need to convert it to an int. The catch is that some other list elements contain numbers, so I can't just convert a list element containing numbers to an int because I get an error.
I tried this:
aList = ['a3','orange','-1','33']
for aLine in aList:
for token in aLine:
if token.isdecimal() == True:
map(int, aLine)
elif token in "0123456789" and token.isalpha() == False:
map(int, aLine)
...Which did absolutely nothing to my list.
I'm hoping to get this kind of output:
['a3', 'orange', -1, 33]