Very basic question probably, but writing my first program and did not know what to search for to find the answer.
I have a while statement that looks something like this:
while number > 9999 or number < 0 or number == 1111 or number == 2222 or number == 3333...
And goes on until I get to 9999. Lots of code that probably can be shortened, am I correct? Not sure about where I could read about the grammar for this, so someone could also link me there!
Would be glad if anyone could help! :)
Use the modulo operator:
while number > 9999 or number < 0 or (number % 1111 == 0 and number != 0):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With