I'm very new to programming and just made an addition loop that will, once age is given, count up from one only stopping when it hits the user's age (e.g. if I say I am 15, the computer will then count up from one until it hits 15).
My current goal is to try and get it to print out ONLY the odd or even numbers until it hits the age. Odd if the age is odd, even if the age is even.
age = int(input("What is your age?: "))
count = 1
while count != age:
print(count)
count += 1
if count == age:
print(age)
break
I've been looking for a long time about how I can print out only these numbers, but I haven't been able to find anything that works outside of a list. I just need some help on applying it to this program. I had written something like this, but I couldn't get it to work with this specific program. I'm having trouble putting it into this one.
if age % 2 != 0:
print(age, end = " ")
Part of this is probably me being too new to be able to do this, and I think that the code right above only works if it has a list to look at. Any tips putting me in the right direction are much appreciated.