Flying home
Your boss assigned you to a small project. They are performing an analysis of the travels people made to attend business meetings. You are given a dataset with only the email subjects for each of the people traveling.
You learn that the text followed a pattern. Here is an example:
Here you have your boarding pass LA4214 AER-CDB 06NOV
.
You need to extract the information about the flight:
- The two letters indicate the airline (e.g
LA
), - The 4 numbers are the flight number (e.g.
4214
). - The three letters correspond to the departure (e.g
AER
), - The destination (
CDB
), - The date (
06NOV
) of the flight.
All letters are always uppercase.
The variable flight
containing one email subject was loaded in your session. You can use print()
to view it in the IPython Shell.
This exercise is part of the course
Regular Expressions in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import re
____