Is it possible for to have a python while loop purely on one line, I\'ve tried this:
while n<1000:if n%3==0 or n%5==0:rn+=n
But it produ
In your example, you try to collapse two levels of blocks / indentation into a single line, which is not allowed. You can only do this with simple statements, not loops, if statements, function definitions etc. That said, for your example there is a workaround using the ternary operator:
while n < 1000: rn += n if (n % 3 == 0 or n % 5 == 0) else 0
which reads as 'add n to rn if the condition holds, else add 0'.