String methods in Python are easy 🧵

  Рет қаралды 78,879

Bro Code

Bro Code

Күн бұрын

#Python #string #methods
00:00:00 useful string methods
00:08:05 exercise
name = input("Enter your name: ")
phone_number = input("Enter your phone #: ")
length = len(name)
index = name.find(" ")
name = name.capitalize()
name = name.upper()
name = name.lower()
result = name.isdigit()
result = name.isalpha()
result = phone_number.count(" ")
phone_number = phone_number.replace("-", "")

Пікірлер: 81
@BroCodez
@BroCodez Жыл бұрын
# ------------------------------- # STRING METHODS # ------------------------------- # name = input("Enter your name: ") # phone_number = input("Enter your phone #: ") # length = len(name) # index = name.find(" ") # name = name.capitalize() # name = name.upper() # name = name.lower() # result = name.isdigit() # result = name.isalpha() # result = phone_number.count(" ") # phone_number = phone_number.replace("-", "") # ------------------------------- # EXERCISE # ------------------------------- username = input("Enter a username: ") if len(username) > 12: print("Your name can't be more than 12 characters") elif not username.find(" ") == -1: print("Your username can't contain spaces") elif not username.isalpha(): print("Your username can't contain digits") else: print(f"Welcome {username}!")
@locomogaku633
@locomogaku633 8 ай бұрын
info1 = print("your username has to be between 3 and 12 characters long!") info2 = print("your username cant contain spaces and digits!") username = input("Please enter your username: ") if username.isdigit() or not username.isalpha(): print(f"{username} is not a valid username!") elif len(username) = 13: print(f"{username} is not a valid username!") else: print(f"Welcome {username}!!!") this is how I did it, thx for the tutorials man I used .isalpha to check for spaces:)
@S.H.I.E.L.D_EDITS
@S.H.I.E.L.D_EDITS Жыл бұрын
Every programming language is easy when explained by bro😎
@Lit35
@Lit35 7 ай бұрын
did you quit sir?
@enespinar9711
@enespinar9711 4 ай бұрын
@@Lit35 Dude do you need help?
@Lit35
@Lit35 4 ай бұрын
@@enespinar9711 i quit and started Roblox scripting lol but i might come back. I hate when you learn smth new u eventually quit. Bro dont be like me just keep going
@TheeKariuki-vy4ub
@TheeKariuki-vy4ub 3 ай бұрын
Very true
@farragoprismproductions3337
@farragoprismproductions3337 7 күн бұрын
_Brooo.._ 😎
@elitegaming8565
@elitegaming8565 6 ай бұрын
Hi Bro, Your HTMl, CSS and Javascript course is mind-blowing
@hussainmalik1718
@hussainmalik1718 3 ай бұрын
This is THE BEST video about string methods on internet..... THE BEST>>>>>> Excellent..It made me understand everything about string methods...... Thankk you Sir...
@therealestice3780
@therealestice3780 Жыл бұрын
I love when you implement Exercises in your Videos! Im new to programming and love solving these on my own ;P like for example i checked for numbers using isdigit insead of isalpha but it still worked. Keep up the good work
@alizamalik9396
@alizamalik9396 7 ай бұрын
age = float(input('ENTER YOUR AGE: ')) if age >= 18: b = input('ENTER YOUR USERNAME: ') name= len(b) if name > 12: print('YOUR USERNAME IS MORE THAN 12 LETTERS') elif b.count(' ') > 0 : print('YOUR USERNAME CONTAINS A SPACE') elif b.isdigit : print('YOUR USERNAME CONTAINS A DIGIT') else: print(f"YOUR USERNAME IS SET TO '{b}' ") else: print('YOU MUST BE 18+ TO SIGN UP')
@user-is2we4bd6b
@user-is2we4bd6b 10 ай бұрын
extremely well explained.,.,thanks for your effort
@joncaldwell4753
@joncaldwell4753 3 күн бұрын
Thanks a lot brother code
@kszoknyik
@kszoknyik 11 ай бұрын
watching your videos as part of my revision :)
@user-pc6bg8kh5v
@user-pc6bg8kh5v 9 ай бұрын
thank you for explaining this so well!
@enviableace9987
@enviableace9987 Ай бұрын
You're the first person where I was able to solve the exercises at the end, I feel really proud of myself, thanks
@mateo1481
@mateo1481 Жыл бұрын
You're great man, i'm enjoying a lot this course
@yunghotigbony
@yunghotigbony 4 ай бұрын
So helpful, thank you!
@user-ly5we6xl4v
@user-ly5we6xl4v 6 ай бұрын
NICELY DONE BRO...❤
@TheMotorcycleBoss
@TheMotorcycleBoss 10 ай бұрын
Your vids are incredibly helpful. How do you find or think of these practice programs?
@Abzarad
@Abzarad Ай бұрын
thanks Bro
@Afot8
@Afot8 4 ай бұрын
U R AWESOME
@TypicalVole2437
@TypicalVole2437 Жыл бұрын
thanks bro
@ChinzzaaaPizza1409
@ChinzzaaaPizza1409 5 ай бұрын
I love how you include exercises in your videos .But i actually used this code in the exercise: print('Username must not contain more than 12 letters') print('Must not contain spaces') print("And must not contain any digit") print('') user_n = input("Enter a username--") len(user_n) if len(user_n) > 12: print("Invalid username as it has too many chracters.") elif user_n.count(" ") != 0:#can/should also use user_n.find(" ") print(f"Invalid username as it contains {user_n.count(" ")} space/s.") elif user_n.isalpha() != True: print(f"Invalid username as it has a digit/s.") else: print("Valid Username !You can sign up...") This also works but one in the video is better
@calculuslifer4024
@calculuslifer4024 Жыл бұрын
Nice bro code
@angryman5517
@angryman5517 6 ай бұрын
i love bro
@rudrarajkar1116
@rudrarajkar1116 Жыл бұрын
Will you make a tutorial series on Kotlin or teach Android development without Android studio please big bro?? I am not able to use Android studio in my low end pc and would love to learn Kotlin from you :)
@user-fc8vj5dy9g
@user-fc8vj5dy9g 6 ай бұрын
nice exercise
@ziggs6845
@ziggs6845 Жыл бұрын
x = input("Nickname: ") while len(x) > 12 or len(x) == 0 or x.isalpha() == False: print("cant be more then 12 characters and cant contain spaces and cant contain digits") x = input("Nickname: ") print("Hi!", x.capitalize())
@naphtalifurst4045
@naphtalifurst4045 Жыл бұрын
Hi can you explain how to write a PID code for Spike prime Robot? thank you
@aungshinthant5858
@aungshinthant5858 Жыл бұрын
Bro or Sir please upload REACTJS tutorial
@thecarzyguyyy9692
@thecarzyguyyy9692 9 ай бұрын
What if I'm typing in spaces AND number, it only show "Your username cannot contains spaces" but not both
@AmericanDragon134
@AmericanDragon134 Жыл бұрын
BRO CODE . JS, TS , Nodejs videos please
@taobattu
@taobattu Жыл бұрын
what playlist this video in?
@ValorantClips1268
@ValorantClips1268 Жыл бұрын
chad
@user-tc5kl8zd5h
@user-tc5kl8zd5h Жыл бұрын
but why it become -1 for cant contain any space
@keeganmahachi9840
@keeganmahachi9840 20 күн бұрын
I did mine but i only used AND operators
@strich3dofficial
@strich3dofficial Жыл бұрын
3rd commmmment
@pictureart23
@pictureart23 8 ай бұрын
OMG I`M THE 100TH LIKE
@stryjo
@stryjo Жыл бұрын
Hello Everyone! My take on it is: username=input(print("Enter Username:")) if len(username)>12 or username.find(" ")>=0 or not username.isalpha(): print("Wrong username! It CANNOT: * be more than 12 characters * contain spaces * contain numbers ") else: print(f"Welcome {username}!")
@stonestone9001
@stonestone9001 Жыл бұрын
Bro, change username=input(print("Enter Username:")) to username=input("Enter Username:"), exlcude the "print" and try again.
@martinnikolov638
@martinnikolov638 Жыл бұрын
I think your code is wrong. What if the username contains a special symbol like "$" - it returns "can't contain digits" but this is not in the conditions
@el_ciprix
@el_ciprix Жыл бұрын
I’m the last you can do: def check_username(username); If len(username) > 12: print(“Your username can’t be more than 12 characters “) elif not username.find(“ “) == -1: print(“Your username can’t contain spaces!”) for i in username: If type(i) == int: print(“Your username can’t contain numbers”)
@user-tc5kl8zd5h
@user-tc5kl8zd5h Жыл бұрын
why it contain the spaces so it become -1??
@shemyemantecle4703
@shemyemantecle4703 Жыл бұрын
2nd comment
@chuk90
@chuk90 8 ай бұрын
09:17: Why this code needs to have a 'f' string behind "Welcome {username}")? While the others dont?
@AbhayRajKarun
@AbhayRajKarun 6 ай бұрын
f string is for inserting variable in a string inside of {}
@olivergrim7634
@olivergrim7634 6 күн бұрын
@@AbhayRajKarun f string is top
@enochnelson4992
@enochnelson4992 Ай бұрын
nice ved :)
@yusra-wk6gj
@yusra-wk6gj 2 күн бұрын
name = input("what is your name: ") name = name.title() sub1 = len(name) if sub1 >=10: print("name is grater then 10") else: print("hello," + name) age = int(input("how old are you: ")) if age >=100: print("how are you even alive") elif age
@diamondemerald6271
@diamondemerald6271 4 ай бұрын
.isdigit looks in a str for int and returns a bool 🤔🤨😵‍💫
@choice3106
@choice3106 7 күн бұрын
Can someone explain why did he used == -1 in 10:54
@olivergrim7634
@olivergrim7634 6 күн бұрын
if you watched the whole video through he explained that if theres no such char found it returns -1
@tretzle2733
@tretzle2733 Жыл бұрын
So now i know how these stupid websites program me to enter a password with letters and numbers
@olivergrim7634
@olivergrim7634 6 күн бұрын
well actually, you might wanna look for the html tutorial
@njihfospep4977
@njihfospep4977 10 ай бұрын
I read a few codes that the commentators and realized that my code is shit name = input("Enter your username:" ) if len(name) > 12: print (f"Your username is too long") elif name.isdigit(): print (f"{name} is not valid symbols") elif not name.isalpha(): print (f"{name} is not valid symbols") else: print(f"Hello {name}!")
@yusra-wk6gj
@yusra-wk6gj 2 күн бұрын
username = input("what is your username: ") num1 = len(username) if num1 >12: print("this username can only be 12 letters long ") elif not username.find(' ') == -1: print("username invalid due to space lease fix it") elif not username.isalpha (): print("username can not cointain digits") else: print(f"Hello, {username}
@rutesh1902
@rutesh1902 10 ай бұрын
def main(): name = input("Type a Name #: ") z= filter(name) print(z) def filter(x): if len(x) > 12: return("Name can't be more than 12 characters") elif not x.find(" ")==-1: return("Name can't have any spaces") elif not x.isalpha(): return("Name can't contain numbers") else: return (f"Your Name is {x}") main()
@Lit35
@Lit35 7 ай бұрын
u still programming?
@shrek1435
@shrek1435 5 ай бұрын
why didn t bro just replace input with bro code
@olivergrim7634
@olivergrim7634 6 күн бұрын
readability
@user-wd4co3nu4h
@user-wd4co3nu4h 8 ай бұрын
name = input("type name ") if len(name) > 12: print("type less bykvi blyaat") elif name.find("suka") != -1: print("ne pishi suka, suka") elif not name.isalpha(): print("dont use digits suka") else: print(f"hello {name} suka ")
@nneural
@nneural Жыл бұрын
hey @BroCode so here is what i wrote when we did the exercise: username = input("Enter a username: ") usernamechar = username.count("") usernamevalid = username.isalpha() if usernamechar > 12: print(f"Username: {username} is not a valid username") elif not usernamevalid: print(f"Username: {username} is not a valid username") else: print(f"Username: {username} is valid") It worked just fine for me and i was wondering if there may be any sort of reason to use this instead of your way.
@olivergrim7634
@olivergrim7634 6 күн бұрын
its more readable
@visheshmukherjee9458
@visheshmukherjee9458 Жыл бұрын
Bro.isGigaChad() #true
@giornogiovanna6871
@giornogiovanna6871 9 ай бұрын
def checknum(text): for i in text: if i.isnumeric(): return False else: return True username = input('enter username: ') if len(username)
@biofluidity2318
@biofluidity2318 Жыл бұрын
print("Your username should be less than 12 / should not contain spaces! / should not contain digits.") username = input('Input ur username: ') if len(username) < 12 and username.isalpha(): print('welcome bro') else: print("Your username should be less than 12 / should not contain spaces! / should not contain digits.")
@edwardnorwood6837
@edwardnorwood6837 Жыл бұрын
username = input("Enter a username: ") username.find(" ") if len(username) > 12: print("Your username cannot be more than 12 characters") elif not username.find(" ") == -1: print("Your username cannot contain spaces") elif not username.isdigit(): print("Your username cannot contain digits") else: print(f"Welcome {username}!")
@RahulSingh-xd4qj
@RahulSingh-xd4qj Жыл бұрын
why cant we simply use not name.find(" ")
@olivergrim7634
@olivergrim7634 6 күн бұрын
@@RahulSingh-xd4qj .find doesnt return bool
@niceballz243
@niceballz243 Жыл бұрын
Added a password feature print("Enter your username.") name = input(": ") if len(name) > 12: print("Username cant contain more then 12 characters") if name.find(" ") >= 0: print("Username cannot contain spaces") elif not name.isalpha(): print("Username cannot contain digits") else: print("Just remember that your password must meet the requirements.") print("-Min 8 characters") print("-Must contain digits") print("-Cannot contain spaces") print("Now please enter you password.") password = input(": ") if len(password) < 8: print("Your password is too short!") elif password.isalpha(): print("Your password must contain at least one digit!") elif not password.find(" ") == -1: print("Your password cannot contain spaces!") else: last = password[-2:] print(f"Hey {name.upper()}, welcome to the club!") print(f" Your password is XXXX-{last}") lastmess = "you have succesfully singed up!!!" print(lastmess.upper())
@Oskar_guitar
@Oskar_guitar Жыл бұрын
Hey, in 10:20 why I cannot use : elif username.find(" ") == 1:
String indexing in Python is easy ✂️
7:28
Bro Code
Рет қаралды 49 М.
Python lists, sets, and tuples explained 🍍
15:06
Bro Code
Рет қаралды 225 М.
Bro be careful where you drop the ball  #learnfromkhaby  #comedy
00:19
Khaby. Lame
Рет қаралды 51 МЛН
Make me the happiest man on earth... 🎁🥹
00:34
A4
Рет қаралды 5 МЛН
Python's 5 Worst Features
19:44
Indently
Рет қаралды 83 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 305 М.
How To Use List Comprehension In Python
6:41
Taylor's Software Solutions
Рет қаралды 3,7 М.
Python Object Oriented Programming in 10 minutes 🐍
10:04
Bro Code
Рет қаралды 340 М.
ALL 47 STRING METHODS IN PYTHON EXPLAINED
23:34
Indently
Рет қаралды 114 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 348 М.
Functions in Python are easy 📞
10:38
Bro Code
Рет қаралды 382 М.
5 Useful Dunder Methods In Python
16:10
Indently
Рет қаралды 50 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 146 М.
Python string format 💬
12:47
Bro Code
Рет қаралды 29 М.
Bro be careful where you drop the ball  #learnfromkhaby  #comedy
00:19
Khaby. Lame
Рет қаралды 51 МЛН