String methods in Python are easy 〰️

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.พ. 2025

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

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

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

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

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

    Every programming language is easy when explained by bro😎

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

      did you quit sir?

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

      @@Lit35 Dude do you need help?

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

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

      Very true

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

      _Brooo.._ 😎

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

  • @thirdworldhermit
    @thirdworldhermit 3 หลายเดือนก่อน +8

    I'm new to coding and i will say, this is the best coding tutorial channel on TH-cam!

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

      trueee

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

      index = name.rfind("e")

  • @alizamalik04
    @alizamalik04 ปีที่แล้ว +19

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

  • @enviableace9987
    @enviableace9987 9 หลายเดือนก่อน +3

    You're the first person where I was able to solve the exercises at the end, I feel really proud of myself, thanks

  • @T_ootie_x_P_atootie
    @T_ootie_x_P_atootie ปีที่แล้ว +5

    watching your videos as part of my revision :)

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

    nice exercise

  • @Rebecca-j4j
    @Rebecca-j4j ปีที่แล้ว

    extremely well explained.,.,thanks for your effort

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

    Nice bro code

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

    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

  • @lucky-ln1yo
    @lucky-ln1yo 4 หลายเดือนก่อน

    i love this :D

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

    U R AWESOME

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

    bro code is the best teacher

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

    with my upcoming exam this vid is a real helper

  • @WINDOWSUSER-q4s
    @WINDOWSUSER-q4s ปีที่แล้ว

    NICELY DONE BRO...❤

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

    Respect to you man

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

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

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

    Thanks a lot brother code

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

    thanks Bro

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

    thanks bro

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

    i love bro

  • @AestheticBlue13
    @AestheticBlue13 7 หลายเดือนก่อน +1

    My Own Code! Still getting there as a beginner :)
    print("---Welcome to SliceN'Dice---")
    # Menu: Cheese Pizza, Pepperoni Pizza, Hawaiian Pizza, BBQ Pizza
    pizza = input("What type pizza would you like to purchase? (CP, PP, HP, BBQ): ")
    pizza_size = input("How big would you like your pizza to be? (S, M, L): ")
    if pizza == "CP" and pizza_size == "S":
    print("Here is your Small Cheese Pizza!")
    elif pizza == "CP" and pizza_size == "M":
    print("Here is your Medium Cheese Pizza!")
    elif pizza == "CP" and pizza_size == "L":
    print("Here is your Large Cheese Pizza!")
    elif pizza == "PP" and pizza_size == "S":
    print("Here is your Small Peperoni Pizza!")
    elif pizza == "PP" and pizza_size == "M":
    print("Here is your Medium Peperoni Pizza!")
    elif pizza == "PP" and pizza_size == "L":
    print("Here is your Large Peperoni Pizza!")
    elif pizza == "HP" and pizza_size == "S":
    print("Here is your Small Hawaiian Pizza!")
    elif pizza == "HP" and pizza_size == "M":
    print("Here is your Medium Hawaiian Pizza!")
    elif pizza == "HP" and pizza_size == "L":
    print("Here is your Large Hawaiian Pizza!")
    elif pizza == "BBQ" and pizza_size == "S":
    print("Here is your Small Barbeque Pizza!")
    elif pizza == "BBQ" and pizza_size == "M":
    print("Here is your Medium Barbeque Pizza!")
    elif pizza == "BBQ" and pizza_size == "L":
    print("Here is your Large Barbeque Pizza!")
    else:
    print(f"Error {pizza_size} {pizza} is not on the menu.")
    print("Order something on the menu.")

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

    Thanks 👍

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

    So helpful, thank you!

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

    thank you for explaining this so well!

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

    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

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

    Thank you my bro, i have exam tmrw and this guide is goated on string functions ill check on your channel regularly to bro-ify python 💪

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

    Holy shit, this taught me better than my programming teacher

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

    3rd commmmment

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

    this guys goated

  • @thecarzyguyyy9692
    @thecarzyguyyy9692 ปีที่แล้ว +4

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

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

    OMG I`M THE 100TH LIKE

  • @Лина-г2ф8э
    @Лина-г2ф8э หลายเดือนก่อน

    I think the exercise is easier this way:
    users_input=input ("enter input ")
    if len(users_input) < 12 and users_input.isalpha():
    print("input valid")
    else:
    print("input not valid")

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

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

    nice ved :)

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

    Why do we use elif not here? Can someone explain in detail to help me understand better.
    Thanks in advance

  • @sakshim2005
    @sakshim2005 29 วันที่ผ่านมา

    user_name = str(input("Please enter your name: "))
    def check():
    if len(user_name)

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

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

  • @stryjo
    @stryjo 2 ปีที่แล้ว +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.

  • @Unwanted-ug8ds
    @Unwanted-ug8ds 12 วันที่ผ่านมา

    also in place of isalpha cant we use isdigit() ??

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

    text = input("Enter your text: ")
    find = input("Enter the word to find: ")
    print(f"The word you looking for is at index number {text.find(find)}")
    How about that?

  • @Piktro
    @Piktro 6 หลายเดือนก่อน +1

    My solution to the exercise:
    isValid = False
    while not isValid:
    username = input("Enter your username: ")
    if len(username) > 12:
    print("Username must be less than 12 characters")
    continue
    elif not username.find(" ") == -1:
    print("Username must not contain any spaces.")
    continue
    elif not username.isalpha():
    print("Username must be alphanumeric")
    continue
    else:
    print(f"Welcome {username}!")
    isValid = True

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

    09:17: Why this code needs to have a 'f' string behind "Welcome {username}")? While the others dont?

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

      f string is for inserting variable in a string inside of {}

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

      @@AbhayRajKarun f string is top

  • @ゴックグエン
    @ゴックグエン ปีที่แล้ว +1

    but why it become -1 for cant contain any space

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

    2nd comment

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

    BRO CODE . JS, TS , Nodejs videos please

  • @rudrarajkar1116
    @rudrarajkar1116 2 ปีที่แล้ว

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

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

    Bro or Sir please upload REACTJS tutorial

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

    Thoroughly convinced he founded python even though I know the guy who did. Bro code just explains things too well for him to not be Guido van Rossum

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

    I did mine but i only used AND operators

  • @yusra-wk6gj
    @yusra-wk6gj 8 หลายเดือนก่อน

    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

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

    chad

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

    what playlist this video in?

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

    Why is the order matter?

  • @ҟіӏӏ
    @ҟіӏӏ 3 หลายเดือนก่อน

    username = input("What is your username: ")
    if len(username) > 12:
    print("The username shall not contain more then 12 characters.")
    if username.isdigit():
    print("The username shall not contain digits.")
    if username.count("") > 1:
    print("The username shall not contain spaces.")

  • @naphtalifurst4045
    @naphtalifurst4045 2 ปีที่แล้ว

    Hi
    can you explain how to write a PID code for Spike prime Robot?
    thank you

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

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

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

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

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

    who? aing oey who ami😂

  • @T_xb
    @T_xb 5 หลายเดือนก่อน +1

    can someone explain whats an f string

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

      a way to embed expressions inside string literals in Python, using curly braces {}. They provide an easy and readable way to format strings dynamically. sentence = f"My name is {name} and I am {age} years old." otherwise it would have been name =("My name is",name)

  • @Kyoogz
    @Kyoogz 2 ปีที่แล้ว

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

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

    why didn t bro just replace input with bro code

  • @РичардПагава
    @РичардПагава ปีที่แล้ว

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

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

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

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

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

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

      u still programming?

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

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

  • @CHRISTISKING-LIGHTOFTHEWORLD
    @CHRISTISKING-LIGHTOFTHEWORLD 2 หลายเดือนก่อน

    user = input("Hello welcome create your user name: ")
    length = len(user)
    if user.strip().count(" "):
    print("Your user name cannot contain any spaces")
    elif length > 12:
    excess_l = length - 12
    print("Im sorry but your user name cant contain more than 12 characters")
    print(f"Your user name is {excess_l} characters too long")
    elif user.isdigit():
    print("Your username cannot contain any digit")
    else:
    print(f"Welcome {user} to website ")

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

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

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

      well actually, you might wanna look for the html tutorial

  • @MSCAntwerpn
    @MSCAntwerpn 10 วันที่ผ่านมา

    name=input("enter the name :")
    if len(name) > 12 :
    print("no more than 12 character")
    elif " " in name:
    print(" no spaces ")
    elif not name.isalpha():
    print(" no digits in name ")
    else:
    print(f" hello {name}")

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

    nome = input("Insira seu nome de usuario (maximo 12, sem espaco e numeros): ")
    if len(nome) < 12 and nome.count(" ") == 0 and nome.isalpha() == True:
    print(f"Bem vindo {nome} owo uwu")
    else:
    print("Nome de usuario invalido ")

  • @yusra-wk6gj
    @yusra-wk6gj 8 หลายเดือนก่อน

    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}

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

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

    Bro.isGigaChad()
    #true

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

    I did it like this and it worked w/o cheating
    username = str(input('Type your user name here :'))
    if len(username) > 12:
    print('your username cant be more than 12 characters!')
    elif not username.find(' ') == -1:
    print('your username cant contain any spaces!')
    elif username.isdigit:
    print('your username cant contain any numbers!')
    else:
    print(f'Hello {username}')

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

    Hey! Isalpha() is checking much more than digits and instructions were digits. We would need to find() or count() every digit [1, 2, 3, 4…] something like that I think 😅

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

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

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

  • @mohammedalmontasir6914
    @mohammedalmontasir6914 4 วันที่ผ่านมา

    that was great but I'm a bit confused why do we have to type
    (elif not usename.isalpha) and not just (elif usename.isalpha) can some one explain it to me please🤷🏾‍♂🤷🏾‍♂

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

      .isalpha() checks if the string contains only alphabetical characters. if it does, it returns True, if it contains non-alphabetical characters such as numbers, it returns False. by using the "not" operator he reverses this. if the username contains numbers, it will now return True.
      not false = true
      not true = false
      if not username.isalpha() is true then that means the username contains numbers. without the "not" you would checking if the username *DOESN'T* contain numbers.

  • @edwardnorwood6837
    @edwardnorwood6837 2 ปีที่แล้ว

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

      @@RahulSingh-xd4qj .find doesnt return bool