Python email slicer exercise 📧

  Рет қаралды 50,612

Bro Code

Bro Code

Күн бұрын

Пікірлер: 48
@BroCodez
@BroCodez 2 жыл бұрын
email = input("Enter your email: ") username = email[:email.index("@")] domain = email[email.index("@") + 1:] print(f"Your username is {username} and domain is {domain}")
@omgitsmcj3420
@omgitsmcj3420 2 жыл бұрын
Thank you
@beepbeepgamer1305
@beepbeepgamer1305 2 жыл бұрын
i prefer partition over index slicing but for the given logic is useful tho.
@qaisherzallah
@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-v5e
@Computer-v5e 3 ай бұрын
Thank you master bro
@dragomirpetrov5138
@dragomirpetrov5138 2 жыл бұрын
You really make coding look easy. This is coming from a guy who just finished your C course :D
@migukau
@migukau 6 ай бұрын
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.
@ugyenofficial
@ugyenofficial 2 жыл бұрын
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
@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}')
@Camaron242
@Camaron242 7 ай бұрын
That’s what I thought would’ve been the most straightforward method
@beepbeepgamer1305
@beepbeepgamer1305 2 жыл бұрын
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 😎😎
@johnpratt3570
@johnpratt3570 2 жыл бұрын
Love you man!!!! You inspire us all!!!!
@kashmirtechtv2948
@kashmirtechtv2948 Ай бұрын
you are amaizng
@kapibara2440
@kapibara2440 Жыл бұрын
Great video ❤
@dharmawangsa9592
@dharmawangsa9592 2 жыл бұрын
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
@vkamalesh9387
@vkamalesh9387 2 жыл бұрын
thank you bro
@fabienekoutesone6046
@fabienekoutesone6046 Жыл бұрын
Thank u Bro
@gian-mm9kr
@gian-mm9kr Жыл бұрын
Hey, could you explain to me the difference between the .index and the .find ?
@h4560
@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-bq8hz
@jomon-bq8hz 5 ай бұрын
@@h4560 thank you 💡💡
@Lit35
@Lit35 Жыл бұрын
took me a while to figure this out
@brunogreco290
@brunogreco290 2 жыл бұрын
Hello. Please make a full course on Springboot framework. Microservices Docker.
@fabulous6202
@fabulous6202 Жыл бұрын
we can also use 'find' method instead of 'index'
@alexandertorres9028
@alexandertorres9028 2 жыл бұрын
Hi bro code could you make a SQL video please have a nice day ;)
@toxicrootvip7264
@toxicrootvip7264 2 жыл бұрын
Thanks Legend
@fmmaks
@fmmaks Жыл бұрын
Why not str.split()?
@omairtech6711
@omairtech6711 Жыл бұрын
LOL I was thinking the same.
@danielhod53
@danielhod53 2 жыл бұрын
what microphone and keyboard you use?
@jeiddoromal4804
@jeiddoromal4804 8 ай бұрын
I just wanna ask what's the purpose or function of +1 ?
@ClashForTheWin
@ClashForTheWin 7 ай бұрын
so that the @ itself shouldn't be printed because when printing domain the @ becomes inclusive
@charitoskalikatzarakis8510
@charitoskalikatzarakis8510 Жыл бұрын
Less lines of code makes the program runs faster?
@ClashForTheWin
@ClashForTheWin 7 ай бұрын
does it?
@J2128H
@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.
@nightwish2803
@nightwish2803 2 жыл бұрын
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?
@beepbeepgamer1305
@beepbeepgamer1305 2 жыл бұрын
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 😎😎
@SavageScientist
@SavageScientist 2 жыл бұрын
python, gangsta language LOL
@Gooseknuckle
@Gooseknuckle 2 жыл бұрын
Bro, do you have a discord server?
@kulanimanganye
@kulanimanganye Жыл бұрын
Hey, where can I practice this ? On github or ?
@ehraz786
@ehraz786 5 ай бұрын
Can remove 2 more lines if you want 😂
@chip0k
@chip0k 11 ай бұрын
my solution: username, domain = email.split('@')
@arshiaa104
@arshiaa104 2 жыл бұрын
Comment
@avivsmadja9159
@avivsmadja9159 2 жыл бұрын
email = input("Enter your email: ") print(f"Your username is {email[:email.index("@")]} and domain is {email[email.index("@") + 1:]}") less lines of Code
@shakil1766
@shakil1766 2 жыл бұрын
f-string: unmatched
@MAT.H404
@MAT.H404 2 жыл бұрын
email = input("Enter your email: ") name = email email = email.find("@") name = name[email+1:] print(name)
@ananyahc8589
@ananyahc8589 5 ай бұрын
email.find("@") does the same job as email.index("@")
Format specifiers in Python are awesome 💬
5:21
Bro Code
Рет қаралды 93 М.
Learn Python OOP in under 20 Minutes
18:32
Indently
Рет қаралды 188 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
AMT2 - Extracting Emails from your Gmail Inbox using python
16:02
DigitalSreeni
Рет қаралды 38 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 467 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
How to Send Emails with Python [New Method 2023]
11:16
The PyCoach
Рет қаралды 205 М.
How I Would Learn Python FAST (if I could start over)
12:19
5 Useful Dunder Methods In Python
16:10
Indently
Рет қаралды 68 М.
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 91 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 275 М.
Let's code a beginner Python BANKING PROGRAM 💰
15:01
Bro Code
Рет қаралды 354 М.