Python Practice › String Programs › Program 86

Name from an email address

EasyString Programs · 86 of 106

Write a Python program to extract the name part of an email address (without trailing digits).

Advertisement
Input
"student1@gmail.com"
Output
student

Approach

  1. Take the part before “@”, then strip digits from the end.

Solution

Python
email = "student1@gmail.com"name = email.split("@")[0].rstrip("0123456789")print(name)
Output
student
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs