I've been trying to understand if it is possible to use an if statement similar to the likes of what I have demonstrated here below. It is my understand that it is not?
for i in range(10):
if i == (3 or 5) or math.sqrt(i) == (3 or 5):
numbers.append(i)
With this block of code I only get the numbers 3
& 9
, while I should be getting 3, 5, 9
. Is there another way of doing so without listing the code below?
for i in range(10):
if i == 3 or i == 5 or math.sqrt(i) == 3 or math.sqrt(i) == 5:
numbers.append(i)