0

I want to calculate the amount of even/odd numbers in the input in put in but when I make the formula for it it gives me an error: in my case it has to have a loop and iteration in the code so cant change anything significantly.

exceptions.TypeError: not all arguments converted during string formatting

The code:

count_odd = None
count_even = None

while True:
    numbers = raw_input("Enter a number: ")
    if numbers == "done": break

    try:
        num = int(numbers)
    except ValueError:
        print "Not a number"
        continue

for x in numbers:
        if x % 2: #error is here
            count_even+=1
        else:
            count_odd+=1

print("Number of even numbers :",count_even)
print("Number of odd numbers :",count_odd)

0 Answers0