Python Practice › String Programs › Program 86
Name from an email address
Write a Python program to extract the name part of an email address (without trailing digits).
Input
"student1@gmail.com"
Output
student
Approach
- Take the part before “@”, then strip digits from the end.
Solution
email = "student1@gmail.com"name = email.split("@")[0].rstrip("0123456789")print(name)Output
student
Learn the concept
New to this topic? Read the lesson, then come back.