In the first code you are iterating over two generators first range(1, 100)
and then over liszt
whereas in the second case the iteration is only over liszt
. Other than that the operation is same in both the cases, so the second method is more efficient.
Since every second number after 1 would be odd, a better solution could be:
for i in range(1, 100, 2):
print(i)