Python: Not All Arguments Converted During String Formatting
This code gives an error print('type a whole number:') n = input() if n % 2 == 1: print('Odd'); else: print('Even'); I'm assuming there's something special I have to do to
Solution 1:
Here is how to fix it:
n = int(input("type a whole number:"))
Since input() returns a string, you need to convert it to an int first, using int().
Solution 2:
Solution 3:
Convert the user input n
to an integer first.
i.e. Simply Change :
n = input()
To :
n = int(input())
Also, input()
can take a string as an argument, which is printed before taking the input.
So, you can change
print('type a whole number:')
n = int(input())
To
n = int(input('type a whole number:'))
Post a Comment for "Python: Not All Arguments Converted During String Formatting"