String methods in Python are easy 🧵

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 มิ.ย. 2024
  • #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("-", "")

ความคิดเห็น • 80

  • @BroCodez
    @BroCodez  ปีที่แล้ว +32

    # -------------------------------
    # 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 ปีที่แล้ว +74

    Every programming language is easy when explained by bro😎

    • @Lit35
      @Lit35 6 หลายเดือนก่อน

      did you quit sir?

    • @enespinar9711
      @enespinar9711 4 หลายเดือนก่อน +1

      @@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 3 วันที่ผ่านมา

      _Brooo.._ 😎

  • @elitegaming8565
    @elitegaming8565 6 หลายเดือนก่อน +7

    Hi Bro, Your HTMl, CSS and Javascript course is mind-blowing

  • @alizamalik9396
    @alizamalik9396 7 หลายเดือนก่อน +4

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

  • @hussainmalik1718
    @hussainmalik1718 3 หลายเดือนก่อน +1

    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 ปีที่แล้ว +10

    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

  • @user-is2we4bd6b
    @user-is2we4bd6b 10 หลายเดือนก่อน

    extremely well explained.,.,thanks for your effort

  • @kszoknyik
    @kszoknyik 11 หลายเดือนก่อน +2

    watching your videos as part of my revision :)

  • @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

  • @user-pc6bg8kh5v
    @user-pc6bg8kh5v 9 หลายเดือนก่อน +1

    thank you for explaining this so well!

  • @mateo1481
    @mateo1481 ปีที่แล้ว +1

    You're great man, i'm enjoying a lot this course

  • @TheMotorcycleBoss
    @TheMotorcycleBoss 9 หลายเดือนก่อน

    Your vids are incredibly helpful. How do you find or think of these practice programs?

  • @yunghotigbony
    @yunghotigbony 3 หลายเดือนก่อน

    So helpful, thank you!

  • @Abzarad
    @Abzarad 26 วันที่ผ่านมา

    thanks Bro

  • @TypicalVole2437
    @TypicalVole2437 ปีที่แล้ว

    thanks bro

  • @Afot8
    @Afot8 3 หลายเดือนก่อน

    U R AWESOME

  • @user-ly5we6xl4v
    @user-ly5we6xl4v 6 หลายเดือนก่อน

    NICELY DONE 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

  • @thecarzyguyyy9692
    @thecarzyguyyy9692 8 หลายเดือนก่อน +2

    What if I'm typing in spaces AND number, it only show "Your username cannot contains spaces" but not both

  • @ziggs6845
    @ziggs6845 ปีที่แล้ว +2

    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

  • @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 :)

  • @angryman5517
    @angryman5517 6 หลายเดือนก่อน

    i love bro

  • @calculuslifer4024
    @calculuslifer4024 ปีที่แล้ว +1

    Nice bro code

  • @user-fc8vj5dy9g
    @user-fc8vj5dy9g 6 หลายเดือนก่อน

    nice exercise

  • @stryjo
    @stryjo ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      Bro, change username=input(print("Enter Username:")) to username=input("Enter Username:"), exlcude the "print" and try again.

  • @aungshinthant5858
    @aungshinthant5858 ปีที่แล้ว

    Bro or Sir please upload REACTJS tutorial

  • @taobattu
    @taobattu ปีที่แล้ว

    what playlist this video in?

  • @AmericanDragon134
    @AmericanDragon134 ปีที่แล้ว

    BRO CODE . JS, TS , Nodejs videos please

  • @user-tc5kl8zd5h
    @user-tc5kl8zd5h ปีที่แล้ว +1

    but why it become -1 for cant contain any space

  • @keeganmahachi9840
    @keeganmahachi9840 16 วันที่ผ่านมา

    I did mine but i only used AND operators

  • @martinnikolov638
    @martinnikolov638 ปีที่แล้ว +1

    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

  • @ValorantClips1268
    @ValorantClips1268 ปีที่แล้ว

    chad

  • @shemyemantecle4703
    @shemyemantecle4703 ปีที่แล้ว

    2nd comment

  • @isaacramirez3659
    @isaacramirez3659 6 วันที่ผ่านมา

    What is the difference between a mathod and a function?

    • @olivergrim7634
      @olivergrim7634 วันที่ผ่านมา

      a method is used specifically used for variables, functions can and are anything

  • @strich3dofficial
    @strich3dofficial ปีที่แล้ว

    3rd commmmment

  • @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 วันที่ผ่านมา

      @@AbhayRajKarun f string is top

  • @diamondemerald6271
    @diamondemerald6271 4 หลายเดือนก่อน

    .isdigit looks in a str for int and returns a bool 🤔🤨😵‍💫

  • @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??

  • @choice3106
    @choice3106 3 วันที่ผ่านมา

    Can someone explain why did he used == -1 in 10:54

    • @olivergrim7634
      @olivergrim7634 วันที่ผ่านมา

      if you watched the whole video through he explained that if theres no such char found it returns -1

  • @enochnelson4992
    @enochnelson4992 หลายเดือนก่อน

    nice ved :)

  • @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}!")

  • @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 6 หลายเดือนก่อน

      u still programming?

  • @pictureart23
    @pictureart23 7 หลายเดือนก่อน

    OMG I`M THE 100TH LIKE

  • @tretzle2733
    @tretzle2733 ปีที่แล้ว

    So now i know how these stupid websites program me to enter a password with letters and numbers

    • @olivergrim7634
      @olivergrim7634 วันที่ผ่านมา

      well actually, you might wanna look for the html tutorial

  • @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 ")

  • @shrek1435
    @shrek1435 4 หลายเดือนก่อน

    why didn t bro just replace input with bro code

  • @giornogiovanna6871
    @giornogiovanna6871 8 หลายเดือนก่อน

    def checknum(text):
    for i in text:
    if i.isnumeric():
    return False
    else:
    return True
    username = input('enter username: ')
    if len(username)

  • @nneural
    @nneural ปีที่แล้ว +1

    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.

  • @visheshmukherjee9458
    @visheshmukherjee9458 ปีที่แล้ว +3

    Bro.isGigaChad()
    #true

  • @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.")

  • @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())

  • @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 วันที่ผ่านมา

      @@RahulSingh-xd4qj .find doesnt return bool

  • @Oskar_guitar
    @Oskar_guitar ปีที่แล้ว +1

    Hey, in 10:20 why I cannot use :
    elif username.find(" ") == 1: