Write a basic list comprehension
In this exercise, you will practice what you've learned from the video about writing list comprehensions. You will write a list comprehension and identify the output that will be produced.
The following list has been pre-loaded in the environment.
doctor = ['house', 'cuddy', 'chase', 'thirteen', 'wilson']
How would a list comprehension that produces a list of the first character of each string in doctor
look like? Note that the list comprehension uses doc
as the iterator variable. What will the output be?
This exercise is part of the course
Python Toolbox
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
