0

Need help with a practice question

hello there, i've encountered a problem in a pratie question whereby I cant get the desired output, instead it turned into a string operation. This is in python code. Here is the question: Write a program that takes a number as input and - returns its double, if the number is even - returns its triple, if the number is odd - returns 0, if number is 0 Sample Input: 1 Sample Output: 3 This is the code that I used: number = input() #your code goes here if number == "/2": print(number*2) elif number == "0": print("0") else: print(number*3)

31st Mar 2021, 3:01 PM
Zhi Hong
Zhi Hong - avatar
2 Answers
31st Mar 2021, 3:06 PM
Soumik
Soumik - avatar
0
Soumik thank you it works ! Didnt think of using quotient to do it
31st Mar 2021, 3:12 PM
Zhi Hong
Zhi Hong - avatar