Apr-14-2018, 11:05 PM
Apr-14-2018, 11:26 PM
for a in range(len(sa_data[1])):but if sa_data[1] is iterable why not:
for item in sa_data[1]:where item is your final target.
Apr-15-2018, 12:17 AM
(Apr-14-2018, 11:26 PM)Larz60+ Wrote: [ -> ]Thanks. I realise how stupid the question was. I had already written than into a variable...for a in range(len(sa_data[1])):
As for the second solution, I'm using the number of the elements rather than the data, so the first solution is better for me.
Apr-15-2018, 12:23 AM
No question is a stupid question if you don't know the answer.
Apr-15-2018, 01:03 AM
(Apr-15-2018, 12:17 AM)IAMK Wrote: [ -> ]As for the second solution, I'm using the number of the elements rather than the data, so the first solution is better for me.Actually, no - the first is not better. Please, read https://python-forum.io/Thread-Basic-Nev...n-sequence
Apr-15-2018, 01:50 AM
(Apr-15-2018, 01:03 AM)buran Wrote: [ -> ]Actually, no - the first is not better. Please, read https://python-forum.io/Thread-Basic-Nev...n-sequenceI find it funny how that's a common mistake for people coming from other languages.
Anyway, thanks. I will replace where
range(len())
appears in My Code with enumerate()
.