How would you extract the domain part of an email address (e.g., 'user@example.com') using string split in Python?
1Times asked
Oct 2026Last seen
Oct 2026First seen
💡 Model Answer
Split the email on the '@' character and take the last element: domain = email.split('@')[-1]. This returns 'example.com'. If you need only the top‑level domain, you can further split on '.' and take the last part: tld = domain.split('.')[-1]. The operation is linear in the length of the email string.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500