Skip to content

Commit

Permalink
For loops
Browse files Browse the repository at this point in the history
  • Loading branch information
s2t2 committed Sep 11, 2024
1 parent a4a93be commit 8abf3d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/notes/data-processing/for-loops.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ We saw how we can print and access all items at once. And we saw we can use an i
We can use a **\"for\" loop** to access each item, one at a time:

```{python}
symbols = ["MSFT", "AAPL", "GOOGL", "AMZN", "NFLX"]
for item in symbols:
Expand Down Expand Up @@ -65,9 +66,9 @@ As a best practice, if we have a list of items plural (e.g. `symbols`), we could
```{python}
symbols = ["MSFT", "AAPL", "GOOGL", "AMZN", "NFLX"]
for symbol in symbols:
for symbol in symbols: # IF WE USE SYMBOL HERE IN THE FIRST SLOT...
print("--------")
print(symbol)
print(symbol) # ... WE HAVE TO REFERENCE SYMBOL HERE AS WELL
# NOTHING ELSE, GO TO NEXT ITEM
print("BOTTOM")
Expand Down

0 comments on commit 8abf3d7

Please sign in to comment.