1. Học hỏi
  2. /
  3. Khoa Học
  4. /
  5. Python Toolbox

Connected

Bài tập

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?

Hướng dẫn

50 XP

Các phương án trả lời