instead of: newlist = [] for i in range(1, 100): if i % 2 == 0: newlist.append(i**2) code example
Example: instead of: newlist = [] for i in range(1, 100): if i % 2 == 0: newlist.append(i**2)
newlist = [i**2 for i in range(1, 100) if i%2==0]
newlist = [i**2 for i in range(1, 100) if i%2==0]