Added an example for iterating over a string (#25806)

This commit is contained in:
Naida Agić
2018-12-20 03:00:36 +01:00
committed by Randell Dawson
parent 5bd2e24820
commit 0a03967faa

View File

@ -121,6 +121,26 @@ thank you
[2, 3]
>
```
**Iterate over characters in a string**
```python
for char in "How fun!":
print("Current char: "+char)
```
Output:
```
>
Current char: H
Current char: o
Current char: w
Current char:
Current char: f
Current char: u
Current char: n
Current char: !
>
```
**Iterate over keys in a dictionary (aka hashmap)**