开始使用免费开始使用

Basic list comprehensions

For this task, you will have to create a bag-of-words representation of the spam email stored in the spam variable (you can explore the content using the shell). Recall that bag-of-words is simply a counter of unique words in a given text. This representation can be further used for text classification, e.g. for spam detection (given enough training examples).

We created a small auxiliary function create_word_list() to help you split a string into words, e.g. applying it to 'To infinity... and beyond!' will return ['To', 'infinity', 'and', 'beyond'].

本练习是课程的一部分

Practicing Coding Interview Questions in Python

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Convert the text to lower case and create a word list
words = ____
编辑并运行代码