I have been trying to make a Basic if-else code of Even-odd number in one line whose output must contain only one type of number(even or odd), I tried the following code:
for i in range(10):
print(i) if i%2!=0 else pass
But the output shows me a syntax error like this:
File "<stdin>", line 2
print(i) if i%2!=0 else pass
^
SyntaxError: invalid syntax
After searching and trying, I got to know that "pass" or "continue" do not work in this way. I wanted to know the reason behind this.