Write a list comprehension in python to get a list of even numbers when a range is given


Topic: Write a list comprehension in python to get a list of even numbers when a range is given

Solution

N = 20
number_list = [ x for x in range(N) if x % 2 == 0]
print(f'List of Even Numbers:', number_list)



List all Python Programs