Purify (and how to get a list as input)


8.12 purify
I think i am fine with the code inside the function but i would like to work with my input.
I know that raw_input() give me a string, until now the only way to make it become a list is the .split() built-in that i just learned, but i don't know well how it works or did some kind of mistake because i read that not all arguments are converted. What i can do? i need a list for make this function work

Traceback (most recent call last):
File "python", line 15, in
File "python", line 4, in purify
TypeError: not all arguments converted during string formatting

def purify (numbers):
    for n in numbers:
        if n%2==0:
    return pair
print '                                 Erase the Odd Numbers'
print'Inserire una lista di numeri'
numbers = raw_input('- ')
numbers = numbers.split()

print ' '
print purify(numbers)


you except a user to enter the following:

4 5 5 4

based on your split, this seems to be the case.

well, then you would need to loop over numbers and convert each one to a integer with int() and update/append them to a list


Thanks for the help :slight_smile: useful like usual


you solved it with so little help? I just gave a little notch in the right direction. Impressive you solved it :slight_smile: You can be proud of yourself


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.