Skip to content

Commit 4cb09fa

Browse files
committed
Add solution to new list comprehension exercise
1 parent b498a76 commit 4cb09fa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ch09-lists-tuples-and-dictionaries/2-lists-are-mutable-sequences.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@
3838
# Exercise 7
3939
# Verify that breakfast has three items using len()
4040
print(len(breakfast) == 3)
41+
42+
43+
# Exercise 8
44+
# Create a new list called `lengths` using a list
45+
# comprehension that contains the lengths of each
46+
# string in the `breakfast` list.
47+
lengths = [len(item) for item in breakfast]
48+
print(lengths)

0 commit comments

Comments
 (0)