email = input("Enter your email: ") username = email[:email.index("@")] domain = email[email.index("@") + 1:] print(f"Your username is {username} and domain is {domain}")
@omgitsmcj34202 жыл бұрын
Thank you
@beepbeepgamer13052 жыл бұрын
i prefer partition over index slicing but for the given logic is useful tho.
@qaisherzallah Жыл бұрын
It is a perfect and superuseful excersise but what you did at the last by typing email.index("@") twice is a bad practice btw cuz u are calling the same fuction twice , and this is a bit hard to the memory
@Computer-v5e3 ай бұрын
Thank you master bro
@dragomirpetrov51382 жыл бұрын
You really make coding look easy. This is coming from a guy who just finished your C course :D
@migukau6 ай бұрын
Its important to note that the second method is less efficient because you are calling the index function twice instead of just calling it once.
@ugyenofficial2 жыл бұрын
I just watched after coming back from the the college. You makes the so beautiful. I hope to master python just after m done with JavaScript. Your JavaScript lesson are also the most beautiful part. I love it brother. Thank you!
@harunisiaho Жыл бұрын
Thank you. Very helpful We can also use str.split function as below email = input('Enter your email address: ') username, domain = email.split('@') print(f'Your username: {username} and domain: {domain}')
@Camaron2427 ай бұрын
That’s what I thought would’ve been the most straightforward method
@beepbeepgamer13052 жыл бұрын
Just use the in-built python fuction which is called as ".partition()". What this basically does it, you specify the string object lets say x="This line of code will partition the word banana into 3 different words in a list". Then give another listobject lets say "a". There the code would go like this. >>> a=x.partition("banana") >>>print(a) ["This line of code will partition the word","banana","into 3 different words in a list"] This is very useful for real life applications such as machine learning, keyword identifying, spelling mistake checking and alot more. The return type of this partition is a list of strings where the strings before the word "banana" is a part of string followed by the partitioned word "banana" and then the rest of the string after banana into a sperate one. The length of the separation is always 3 as words before the given word and then word itself and the words after the give word. Partition only works for string datatype and nothing else. So don't forget to give the given word inside in quotes, you could also store the string in a separate object and specify it in inside the parenthesis without the quotes. Hope this gave an alternate method for the same solutions, stay programming always 😎😎
@johnpratt35702 жыл бұрын
Love you man!!!! You inspire us all!!!!
@kashmirtechtv2948Ай бұрын
you are amaizng
@kapibara2440 Жыл бұрын
Great video ❤
@dharmawangsa95922 жыл бұрын
I understand java and data structure after watching your vids. Man you are legend. Can you crate tutorial about spring boot and rest api I know you are good at java
@vkamalesh93872 жыл бұрын
thank you bro
@fabienekoutesone6046 Жыл бұрын
Thank u Bro
@gian-mm9kr Жыл бұрын
Hey, could you explain to me the difference between the .index and the .find ?
@h4560 Жыл бұрын
the difference is that .index will have an error when it’s not able to find what it’s looking for and .find returns a -1 if not able to find what it’s looking for. Other than that they do the same thing where they return the lowest number where the character is found.
@jomon-bq8hz5 ай бұрын
@@h4560 thank you 💡💡
@Lit35 Жыл бұрын
took me a while to figure this out
@brunogreco2902 жыл бұрын
Hello. Please make a full course on Springboot framework. Microservices Docker.
@fabulous6202 Жыл бұрын
we can also use 'find' method instead of 'index'
@alexandertorres90282 жыл бұрын
Hi bro code could you make a SQL video please have a nice day ;)
@toxicrootvip72642 жыл бұрын
Thanks Legend
@fmmaks Жыл бұрын
Why not str.split()?
@omairtech6711 Жыл бұрын
LOL I was thinking the same.
@danielhod532 жыл бұрын
what microphone and keyboard you use?
@jeiddoromal48048 ай бұрын
I just wanna ask what's the purpose or function of +1 ?
@ClashForTheWin7 ай бұрын
so that the @ itself shouldn't be printed because when printing domain the @ becomes inclusive
@charitoskalikatzarakis8510 Жыл бұрын
Less lines of code makes the program runs faster?
@ClashForTheWin7 ай бұрын
does it?
@J2128H Жыл бұрын
just to add to your already excelent content, if i may: you can also achive the same in the follwoing way: email = input("enter your email: ") user_name, domain_name = email.split("@") print(f"your username is {user_name} and your domain name is {domain_name}.") * this only works if you know ahead of time that you're going to recieve two strings after the split.
@nightwish28032 жыл бұрын
Hello bro! I'm a beginner programmer and just started learning java a month ago. I'm not very good at it and I want to improve. I have bad logic and always cant think the other way around and stuck on a method. Is there anyway for me to improve?
@beepbeepgamer13052 жыл бұрын
Just use the in-built python fuction which is called as ".partition()". What this basically does it, you specify the string object lets say x="This line of code will partition the word banana into 3 different words in a list". Then give another listobject lets say "a". There the code would go like this. >>> a=x.partition("banana") >>>print(a) ["This line of code will partition the word","banana","into 3 different words in a list"] This is very useful for real life applications such as machine learning, keyword identifying, spelling mistake checking and alot more. The return type of this partition is a list of strings where the strings before the word "banana" is a part of string followed by the partitioned word "banana" and then the rest of the string after banana into a sperate one. The length of the separation is always 3 as words before the given word and then word itself and the words after the give word. Partition only works for string datatype and nothing else. So don't forget to give the given word inside in quotes, you could also store the string in a separate object and specify it in inside the parenthesis without the quotes. Hope this gave an alternate method for your question, stay programming always 😎😎
@SavageScientist2 жыл бұрын
python, gangsta language LOL
@Gooseknuckle2 жыл бұрын
Bro, do you have a discord server?
@kulanimanganye Жыл бұрын
Hey, where can I practice this ? On github or ?
@ehraz7865 ай бұрын
Can remove 2 more lines if you want 😂
@chip0k11 ай бұрын
my solution: username, domain = email.split('@')
@arshiaa1042 жыл бұрын
Comment
@avivsmadja91592 жыл бұрын
email = input("Enter your email: ") print(f"Your username is {email[:email.index("@")]} and domain is {email[email.index("@") + 1:]}") less lines of Code
@shakil17662 жыл бұрын
f-string: unmatched
@MAT.H4042 жыл бұрын
email = input("Enter your email: ") name = email email = email.find("@") name = name[email+1:] print(name)
@ananyahc85895 ай бұрын
email.find("@") does the same job as email.index("@")