Returning back to learning to code with python.
When I run the code, enter some numbers it will stored as a list by using list() and that list will safe my int(input())
theoreticaly it is just a exercise to guess if its a odd or an even number.. i know, it could be done by simple % 2.
line = list(map(int, input("please enter a number: ")))
x_odd = [1, 3, 5, 7, 9]
x_even = [0, 2, 4, 6, 8]
if line[-1] in x_odd:
print("You entered:" + str(line) + ", " + "the number: " + str(line) + " is Odd")
elif line[-1] in x_even:
print("you entered:" + str(line) + ", " + "the number: " + str(line) + " is Even")
else:
print("you entered not a number")
I except the out of 55 when i enter the number 55 so it shoud be something like this:
You entered: 55, the number: 55 is Odd
what i get is :
You entered:[5, 5], the number: [5, 5] is Odd
it has to be formated into a intiger, but where?
what can i read, to understand how it works ?
thanks in advance :)
Aucun commentaire:
Enregistrer un commentaire