7. Looping over a collection
Avoid using an index to access your elements in the array.
7.1. Don’t do this
1names = ['john', 'jane', 'jeremy', 'janice', 'joyce', 'jonathan']
2
3for i in range(len(names)):
4 print(names[i])
7.2. Do this
1names = ['john', 'jane', 'jeremy', 'janice', 'joyce', 'jonathan']
2
3for name in names:
4 print(name)