[SOLVED] How to let user type a number and then use the function to return that number is odd or even

Issue

This Content is from Stack Overflow. Question asked by Juras

def function(number):
if number % 2 == 0:
number = “even”
return number
else:
number = “odd”
return number
function(input(“5”))



Solution

You would have to take the user-input, and then run the function with the number the user did type. example:

userinput = input("Type a number: ")

then…
print(function(userinput))


This Question was asked in StackOverflow by Juras and Answered by Stian Larsen It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?