dimanche 23 février 2020

Can I use the class of an object in if statement?

The question is : Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user.

My work flow is something like this:

x=int(input("Please enter a number"))
Type=x/2
If type(Type)=int
print ("x is an even number")
else 
print ("x is an odd number")

Can this logic work?

Aucun commentaire:

Enregistrer un commentaire