8000 Update 3-nesting-sorting-and-copying-lists-and-tuples.py · x413/python-basics-exercises@9f5dd66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f5dd66

Browse files
authored
Update 3-nesting-sorting-and-copying-lists-and-tuples.py
1 parent 06c7585 commit 9f5dd66

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ch09-lists-tuples-and-dictionaries/3-nesting-sorting-and-copying-lists-and-tuples.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
# Exercise 2
1111
# Loop over data and print the sum of each nested tuple
12-
for i in range(len(data)):
13-
print(f"Row {i+1} sum: {data[i][0] + data[i][1]}")
12+
index = 1
13+
for row in data:
14+
print(f"Row {index} sum: {sum(row)}")
15+
index += 1
1416

1517

1618
# Exercise 3

0 commit comments

Comments
 (0)
0