Command Palette

Search for a command to run...

Hectal
Phase 3: Strings and Text in Depth
Python · Exercise 3 of 6 PreviousNext
Beginner

Clean and split an email address

raw_email holds " Ravi.Kumar@Example.COM \n", as typed into a form. Make three variables:

email is the cleaned address: no spaces or newline at the ends, all lower case. username is the part before the @. domain is the part after it. (partition("@"), from Topic 3.2, cuts a string at the first @.) Then print ravi.kumar at example.com using an f-string with username and domain.

What Check tests

  1. email is ravi.kumar@example.com
  2. username is ravi.kumar
  3. domain is example.com
  4. raw_email is unchanged and email is not typed in
  5. The program prints ravi.kumar at example.com

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.