I have the following code segments:
def is_even(num):
if(num % 2 == 0):
return True
return False
1.
lista = range(50)
pares = [i for i in lista if is_even(i)]
# pares = [0, 2, 4, 6, 8...]
2.
lista = range(50)
pares = []
for i in lista:
if is_even(i):
pares.append(i)
# pares = [0, 2, 4, 6, 8...]
In this case, should one be used over another? Or is it indifferent? Why?