I have only very recently began to learn python or any programming language but I am struggling to understand why a piece of code behaves how it does.
I am following a course and in the course we are trying to create an app that determines if a number is odd or even.
This is what I wrote initially. I did this as I want to check that number % 2 was giving me the correct information - extremely new and just trying to understand the code I am using.
This failed
number = int(input("Which number do you want to check? "))
check = print(number % 2)
if check == 0:
print("This is an even number")
else:
print("This is an odd number")
However, when I removed print it worked as expected.
number = int(input("Which number do you want to check? "))
check = number % 2
if check == 0:
print("This is an even number")
else:
print("This is an odd number")
I was just curious as to why this might be?
Thank you!