You are viewing a single comment's thread. Return to all comments →
In this case the assumption is that input is between 1 and 20, so we don't expect any other input.
If you wanted to enforce the constraint, the code would be extended to this
[print(i**2) for i in range(n) if n in range(1, 21)]
Seems like cookies are disabled on this browser, please enable them to open this website
Loops
You are viewing a single comment's thread. Return to all comments →
In this case the assumption is that input is between 1 and 20, so we don't expect any other input.
If you wanted to enforce the constraint, the code would be extended to this