I am trying to write a List comprehension for below for loop in python
num_list = []
for num in range(10):
if num % 2 == 0:
num_list.append('EVEN')
else:
num_list.append('ODD')
I wrote something like
[num if num % 2 == 0 'EVEN' else 'ODD' for num in range(10)]
and
[num if num % 2 == 0 then 'EVEN' else 'ODD' for num in range(10)]
but both are giving syntax errors and not valid.
I am new to pyhton, so not sure if this can be translated to a comprehension or not. Any help would be appreciated.