Skip to content

Commit 5d611b8

Browse files
committed
Iterating Over a Dictionary
1 parent 560d0c4 commit 5d611b8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

0010-For-Loops/for_loops.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,22 @@
3636
print(f"{COMMENT} - start")
3737
print()
3838

39-
for i in range(10):
40-
print(i) # Print 10 numbers starting from 0 (0-9)
39+
for char in "Hello":
40+
print(char)
41+
42+
print()
43+
print(f"{COMMENT} - finish")
44+
print("======================================================")
45+
46+
COMMENT = "Iterating Over a Dictionary"
47+
48+
print(f"{COMMENT} - start")
49+
print()
50+
51+
PERSON = {"name": "John", "age": 25, "city": "New York"}
52+
53+
for key, value in PERSON.items():
54+
print(key, ":", value)
4155

4256
print()
4357
print(f"{COMMENT} - finish")

0 commit comments

Comments
 (0)