Python email slicer exercise

Python email slicer exercise

Bro Code

1 год назад

36,287 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@BroCodez
@BroCodez - 21.10.2022 16:02

email = input("Enter your email: ")

username = email[:email.index("@")]
domain = email[email.index("@") + 1:]

print(f"Your username is {username} and domain is {domain}")

Ответить
@harunisiaho
@harunisiaho - 13.11.2023 15:36

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}')

Ответить
@Lit01zz
@Lit01zz - 11.11.2023 22:53

took me a while to figure this out

Ответить
@kapibara2440
@kapibara2440 - 23.10.2023 16:22

Great video ❤

Ответить
@fabulous6202
@fabulous6202 - 08.10.2023 09:46

we can also use 'find' method instead of 'index'

Ответить
@charitoskalikatzarakis8510
@charitoskalikatzarakis8510 - 04.10.2023 17:11

Less lines of code makes the program runs faster?

Ответить
@fabienekoutesone6046
@fabienekoutesone6046 - 01.09.2023 16:14

Thank u Bro

Ответить
@ashokbishwas
@ashokbishwas - 07.07.2023 00:48

Readability matters in python , (fun language) , so previous way is better.

Ответить
@jasonhammerle3582
@jasonhammerle3582 - 28.06.2023 23:15

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.

Ответить
@kulanimanganye
@kulanimanganye - 12.05.2023 04:20

Hey, where can I practice this ?
On github or ?

Ответить
@gian-mm9kr
@gian-mm9kr - 06.05.2023 06:55

Hey, could you explain to me the difference between the .index and the .find ?

Ответить
@fmmaks
@fmmaks - 12.03.2023 16:41

Why not str.split()?

Ответить
@LyricsTurkceKurtce
@LyricsTurkceKurtce - 26.10.2022 22:05

email = input("Enter your email: ")
name = email

email = email.find("@")

name = name[email+1:]

print(name)

Ответить
@beepbeepgamer1305
@beepbeepgamer1305 - 23.10.2022 08:53

Just use the in-built python fuction which is called as ".partition(<give your string here>)". 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 😎😎

Ответить
@avivsmadja9159
@avivsmadja9159 - 22.10.2022 12:03

email = input("Enter your email: ")
print(f"Your username is {email[:email.index("@")]} and domain is {email[email.index("@") + 1:]}")
less lines of Code

Ответить
@SavageScientist
@SavageScientist - 22.10.2022 07:30

python, gangsta language LOL

Ответить
@alexandertorres9028
@alexandertorres9028 - 22.10.2022 06:10

Hi bro code could you make a SQL video please have a nice day ;)

Ответить
@brunogreco290
@brunogreco290 - 22.10.2022 01:21

Hello. Please make a full course on Springboot framework. Microservices Docker.

Ответить
@ugyenofficial
@ugyenofficial - 21.10.2022 21:32

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!

Ответить
@Gooseknuckle
@Gooseknuckle - 21.10.2022 19:35

Bro, do you have a discord server?

Ответить
@nightwish2803
@nightwish2803 - 21.10.2022 19:21

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?

Ответить
@danielhod53
@danielhod53 - 21.10.2022 18:40

what microphone and keyboard you use?

Ответить
@arshiaa104
@arshiaa104 - 21.10.2022 17:46

Comment

Ответить
@dharmawangsa9592
@dharmawangsa9592 - 21.10.2022 17:16

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

Ответить
@dragomirpetrov5138
@dragomirpetrov5138 - 21.10.2022 16:57

You really make coding look easy. This is coming from a guy who just finished your C course :D

Ответить
@johnpratt3570
@johnpratt3570 - 21.10.2022 16:28

Love you man!!!! You inspire us all!!!!

Ответить
@toxicrootvip7264
@toxicrootvip7264 - 21.10.2022 16:16

Thanks Legend <3

Ответить
@vkamalesh9387
@vkamalesh9387 - 21.10.2022 16:04

thank you bro

Ответить