Session Ready
Exercise

More string operators and Twitter

In this exercise, you will apply different string operators to three strings, selected from the tweets dataset. A tweets_list has been created for you.

You need to construct three new lists by applying different string operators:

  • a list retaining only letters
  • a list retaining only characters
  • a list retaining only digits

The required functions have been imported for you from nltk.

Instructions
100 XP
  • Create a list of the tokens from tweets_list.
  • In the list letters remove all digits and other characters, i.e. keep only letters.
  • Retain alphanumeric characters but remove all other characters in let_digits.
  • Create digits by removing letters and characters and keeping only numbers.