[Previous article] Continuing from (), I was reading "Detailed explanation of time-series data processing by deep learning Tensorflfow / Keras". When defining the model structure in, a function called enumerate () was used in the for statement, but I didn't know the contents, so I looked it up.
I used this as a reference. http://www.gesource.jp/programming/python/code/0022.html
enumerate_check.py
a = [(i+1)*10 for i in range(10)]
for index, element in enumerate(a):
print(index, '-', element)
Execution result 0 - 10 1 - 20 2 - 30 3 - 40 4 - 50 5 - 60 6 - 70 7 - 80 8 - 90 9 - 100
enumerate_check2.py
a = [(i+1)*10 for i in range(10)]
for i in range(len(a)):
print(i, '-', a[i])
This was the same result. Is enumerate () better? Is it just a readability issue?