Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
868 views
in Computer by (51.9k points)
closed by

Write a program to read email IDs of n number of students and store them in a tuple. Create two new tuples, one to store only the usernames from the email IDs and second to store domain names from the email ids. Print all three tuples at the end of the program. 

[Hint: You may use the function split()]

1 Answer

+1 vote
by (49.6k points)
selected by
 
Best answer
n = int(input("Enter number of students : "))

list1=[]

for i in range(n):

    email=input("Enter email: ")

    list1.append(email)

tuple1=tuple(list1)

names=[]

domains=[]

for i in tuple1:

    name,domain = i.split("@") #return list of strings break using the string in the argument

    names.append(name) #build names list

    domains.append(domain) #build domains list

names = tuple(names)

domains = tuple(domains)

print("Names = ",names)

print("Domains = ",domains)

print("Tuple = ",tuple1)

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...