Hey, I'm a Python newbie, and I'm not even sure I've correctly interpreted the problem, but from what I gather the idea is to take an integer with an arbitrary number of digits and return two [strings/lists/tuples/whatever]: one containing all of the odd digits, and another containing all of the even digits. This should work:
 

def make_string(words):
    string = " "
    for x in words:
        string = string + x + " "
    return string


def even_odd(num):
    even = []
    odd = []
    num_string = str(num)
    for x in num_string:
        a = int(x)
        if a%2 == 0:
            even.append(x)
        else:
            odd.append(x)
    odd_string = make_string(odd)
    even_string = make_string(even)
    return (odd_string, even_string)



 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to