Skip to content

Commit

Permalink
resolves swcarpentry#582 regarding the use of in-place addition opera…
Browse files Browse the repository at this point in the history
…tors

one instance is left in episode 18 to emphasize the point of the exercise
  • Loading branch information
naclomi committed Feb 8, 2022
1 parent 9e540eb commit eae7ea7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions _episodes/12-for-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ print(total)
> cumulative.append(total)
> for number in data:
> cumulative = []
> total += number
> total = total + number
> total = 0
> print(cumulative)
> data = [1,2,2,5]
Expand All @@ -334,7 +334,7 @@ print(total)
> > data = [1,2,2,5]
> > cumulative = []
> > for number in data:
> > total += number
> > total = total + number
> > cumulative.append(total)
> > print(cumulative)
> > ~~~
Expand Down
8 changes: 4 additions & 4 deletions _episodes/18-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ average(values)
> for j in range(len(s)):
> left = j-1
> right = (j+1)%len(s)
> if s[left]==s[right]: new += '-'
> else: new += '*'
> if s[left]==s[right]: new = new + '-'
> else: new = new + '*'
> s=''.join(new)
> print(s)
> i += 1
Expand Down Expand Up @@ -197,9 +197,9 @@ average(values)
> > left = j-1
> > right = (j+1) % input_string_length # ensure right index wraps around
> > if old[left] == old[right]:
> > new += '-'
> > new = new + '-'
> > else:
> > new += '*'
> > new = new + '*'
> > print(new)
> > # store new string as old
> > old = new
Expand Down

0 comments on commit eae7ea7

Please sign in to comment.