0

If I add +1 after : (semicolon) it prints nothing in domain name in line 3. Why?

https://code.sololearn.com/c2FJpK9mJ8SP/?ref=app

27th Aug 2020, 7:35 AM
Shreyansh
Shreyansh - avatar
2 Réponses
+ 6
The number after the colon ends the string slice at one character before that index position, so 1 after the colon (:) means the last character in the slice is at index 0, i.e. the first character. If there is no number after the colon, the slice goes to the end of the string. See https://code.sololearn.com/cXNzv56rgiyL Btw you can also do it this way: email = input("Enter your email address: ").strip().split("@") email_username = email[0] email_domain = email[1]
27th Aug 2020, 8:14 AM
David Ashton
David Ashton - avatar
0
Thanks a lot ☺️☺️
27th Aug 2020, 11:20 AM
Shreyansh
Shreyansh - avatar