This pertains to the section about Repeating Actions with Loops.
Some of the logic does not appear to follow: we first show indexing of particular elements, i.e. word[0], word[1]..., but do not use actual indices in loops. It would be helpful to show looping both ways, both for char in word and for x in xrange. This would also serve as a conceptual link to the enumerate section at the end.
The text was updated successfully, but these errors were encountered:
If explicit ranges were to be added to the lesson, for x in range would be more appropriate than for x in xrange. The Software Carpentry Python lessons are based on Python 3 (in which xrange is deprecated).
Even so, the transition from word[0], word[1], etc., to loops isn't much of a leap, given the included diagram that pictorially shows how the loop over a string selects each character in sequence.
in the lesson is that it can be seeing as a bad practice, at least in Python. Learners with experience in other languages, e.g. C and Fortran, could decide to always do for i in range(x) instead of for item in x due their similarity with C/Fortran.
This pertains to the section about Repeating Actions with Loops.
Some of the logic does not appear to follow: we first show indexing of particular elements, i.e. word[0], word[1]..., but do not use actual indices in loops. It would be helpful to show looping both ways, both
for char in word
andfor x in xrange
. This would also serve as a conceptual link to theenumerate
section at the end.The text was updated successfully, but these errors were encountered: