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?

4th Apr 2021, 11:52 PM
Cody Benke
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
4th Apr 2021, 11:58 PM
Yami Francø
Yami Francø - avatar
5th Apr 2021, 1:04 AM
Stefan
Stefan - avatar
0
Much appreciated! int(input()) fixed it
5th Apr 2021, 1:43 AM
Cody Benke
0
n = int(input()) if n%2 == 0: print(2*n) elif n%2 != 0: print(3*n) elif n == 0: print(0)
11th Jan 2022, 3:18 PM
José Santos