'%' Python Is Giving Me A "not All Arguments Converted During String Formatting"
I've downloaded the exact version this text asked me to however the '%' is giving me a problem. x = raw_input('Enter an integer:') if x%2 == 0: print '' print 'Even' else:
Solution 1:
The raw_input()
function returns a string, not an integer. To change it to an integer, you have to call the int()
function:
x = int(raw_input('Enter an integer:'))
Note that an error will be raised if you input anything other than a number.
What python thinks you're doing is trying to use string formatting with the %
operator. As there are no "%"
in the string you input, the error "not all arguments converted during string formatting" is raised.
Post a Comment for "'%' Python Is Giving Me A "not All Arguments Converted During String Formatting""