0
Elif Statement Challenge question
Been having an issue with the Elif statement V challenge write a program that takes a number as input and: returns it’s double if the number is even returns its triple if odd Returns 0 if 0 The code I’ve been trying to use is this: number = input() if number % 2 == 0: print(number * 2) elif number % 2 != 0: print(number * 3) elif number == 0: print(0) The output keeps returning with the error “not all arguments converted during string formatting” for Line 2. Not sure what my misstep here is?
4 Respuestas
+ 3
U have to specify the input as int,like this:
number = int(input())
if number % 2 == 0:
print(number * 2)
elif number % 3 == 0:
print(number * 3)
elif number == 0:
print(0)
oh and i changed the line number 4
+ 2
https://code.sololearn.com/cHoWIV3L15Y9/?ref=app
This may help you!
0
Much appreciated! int(input()) fixed it
0
n = int(input())
if n%2 == 0:
print(2*n)
elif n%2 != 0:
print(3*n)
elif n == 0:
print(0)