How do i make a program that prints out only odd numbers from range? PYTHON
from range that the user sets for example: user says "10" output: 1 3 5 7 9
Voters
megapega88
@Saml2020 yeah, i just wanted help on how do i make it print out from not a set number. likei can say 22 or 247 and it wouldn't matter. but thanks for replying
SamDev7
@megapega88 Simply change the
10
in the code above 😉
Use the normal for-loop, but before printing the number, check to see if it is divisible by two or not (the remainder of the number divided by two is 0 if it is divisible). If it isn't, print the number. Otherwise, do nothing.