+ 3
What is this error?
3 Antworten
+ 7
After you have done what @Dan said, the program itself raises the ValueError, you just need to except it. Try doing this:
try:
if int(x) % 2 == 0:
print("The number is even.")
elif int(x) % 2 == 0:
print("The number is odd.")
except ValueError:
print("Please enter numbers and not letters.")
+ 4
Based on the error message, it's complaining that you have an end of line inside the string literal, put it all on one line or use string concatenation so that you don't have an end of line character in there
+ 1
no wait,
set x to global value,
or set x to local value.
#####
#below local
#
x = int(input("num:"))
def oe_local(localx):
if localx...
...
elif localx...
...
else
return None
#####
#below global
#
x = int(input("num:"))
def oe_global():
global x
if x...
...
elif x...
...
else
return None
oe()