31 ESSENTIAL Python String Methods

Strings are an essential data type in Python that are used in nearly every application. In this tutorial we learn about the 31 most important built-in string methods.
Get my Free NumPy Handbook:
www.python-engineer.com/numpy...
✅ Write cleaner code with Sourcery, instant refactoring suggestions in VS Code & PyCharm: sourcery.ai/?... *
⭐ Join Our Discord : / discord
📓 ML Notebooks available on Patreon:
/ patrickloeber
If you enjoyed this video, please subscribe to the channel:
▶️ : / @patloeber
~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~
🖥️ Website: www.python-engineer.com
🐦 Twitter - / patloeber
✉️ Newsletter - www.python-engineer.com/newsl...
📸 Instagram - / patloeber
🦾 Discord: / discord
▶️ Subscribe: / @patloeber
~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~
🅿 Patreon - / patrickloeber
#Python
Timeline:
00:00 - Intro
00:18 - 1. Slicing
00:40 - 2. strip()
02:10 - 3./4. lstrip() and rstrip()
02:35 - 5./6. removeprefix() and removesuffix()
03:16 - 7. replace()
03:37 - 8. re.sub()
04:25 - 9. split()
05:02 - 10. rsplit()
05:24 - 11. join()
05:50 - 12./13./14. upper(), lower(), capitalize()
06:07 - 15./16. islower() and isupper()
06:25 - 17./18./19. isalpha(), isnumeric(), isalnum()
07:05 - 20. count()
07:22 - 21. find()
08:07 - 22. rfind()
08:20 - 23./24. startswith() and endswith()
08:35 - 25. partition()
09:04 - 26./27./28 center(), ljust(), rjust()
09:45 - 29. f-Strings
10:26 - 30. swapcase()
10:40 - 31. zfill()
----------------------------------------------------------------------------------------------------------
* This is an affiliate link. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you so much for the support! 🙏

Пікірлер: 86

  • @lawrencedoliveiro9104
    @lawrencedoliveiro91042 жыл бұрын

    3:09 Just a note that removeprefix and removesuffix are only available in 3.9 or later.

  • @HeyImAK
    @HeyImAK2 жыл бұрын

    Great run-through. Will definitely watch again before starting a string-heavy project.

  • @YM-lm8xr
    @YM-lm8xr2 жыл бұрын

    this is great content and format, please bring us more of this kinda summary !!

  • @dilyornematjon1526

    @dilyornematjon1526

    2 жыл бұрын

    asd

  • @gustavojuantorena
    @gustavojuantorena2 жыл бұрын

    Great format. Super useful!

  • @susanafl3x
    @susanafl3x Жыл бұрын

    Thanks for the examples!

  • @scottterry2606
    @scottterry26062 жыл бұрын

    Great job! To the point and useful.

  • @patloeber

    @patloeber

    2 жыл бұрын

    Glad you think so!

  • 2 жыл бұрын

    Awesome! Thank you for the great content!

  • @dhineshbabu9376
    @dhineshbabu93762 жыл бұрын

    This is really cool bro. Please make more such useful summaries. Thank you

  • @patloeber

    @patloeber

    2 жыл бұрын

    Thanks, will do!

  • @barristar9338
    @barristar93382 жыл бұрын

    Thanks for this, so useful

  • @Viktoriad3
    @Viktoriad3 Жыл бұрын

    Great video, helped me a lot :)

  • @gboyeegs
    @gboyeegs Жыл бұрын

    awesome content for a beginner!!!

  • @justinlee1250
    @justinlee12502 жыл бұрын

    It is very useful as my quick reference of string methods, thanks.

  • @patloeber

    @patloeber

    2 жыл бұрын

    Glad it was helpful!

  • @alyssonmachado1254
    @alyssonmachado12542 жыл бұрын

    Great video! I loved the tips, they are very useful!

  • @patloeber

    @patloeber

    2 жыл бұрын

    Glad you like them!

  • @dilyornematjon1526

    @dilyornematjon1526

    2 жыл бұрын

    bullshit video

  • @name1355_0ne
    @name1355_0ne2 жыл бұрын

    Thank you, some of the methods were unknown to me

  • @duck9597
    @duck95972 жыл бұрын

    Thank you for the video

  • @rinuhasinikarthik5544
    @rinuhasinikarthik5544 Жыл бұрын

    this is extremely good content

  • @haisomeone2218
    @haisomeone2218 Жыл бұрын

    Thanks . I knew everyone of it 😁😁

  • @cancan740
    @cancan740 Жыл бұрын

    very goog video , i learned a lot , thanks

  • @user-yw5jc1fi2l
    @user-yw5jc1fi2l2 жыл бұрын

    ty we need more :)

  • @brookhaile6862
    @brookhaile6862 Жыл бұрын

    fantastic!

  • @vlogofjagathies6287
    @vlogofjagathies6287 Жыл бұрын

    Thanks you so much... I am a 1st year college student before to go to the collage I am started to learning computer languages and successful learned c,cpp and entered to learn python and studying but python is not easy to learn comparing to c, cpp. And get exactly stuked at this topic and now I am clear about this so thank you so much... 😄😄😄

  • @tomblankenship8838
    @tomblankenship88382 жыл бұрын

    thank you very much, i just wonder in the minute 2:08 the strip method why doesnt remove the m in the example word, thanks in advance, great great gift your teachings thank you!

  • @xk999

    @xk999

    2 жыл бұрын

    Because the strip method only works for characters located at the beginning or at the end of a string

  • @anirbanc88
    @anirbanc88 Жыл бұрын

    awesome sir

  • @sukritiguin5637
    @sukritiguin5637 Жыл бұрын

    Just Awesome❤❤❤❤❤❤❤❤

  • @anAlokDubey
    @anAlokDubey2 жыл бұрын

    Great video!!! 😀👍

  • @patloeber

    @patloeber

    2 жыл бұрын

    Thank you! 😀

  • @hemanthmuvvala5652
    @hemanthmuvvala56522 жыл бұрын

    Lots of love

  • @si24.with.u
    @si24.with.u2 жыл бұрын

    tnx

  • @snthabd2836
    @snthabd2836 Жыл бұрын

    Thanks,

  • @lawrencedoliveiro9104
    @lawrencedoliveiro91042 жыл бұрын

    4:14 That only works because “s” has no special meaning after “\”. To be safe in general, you should double the backslash, or use a raw string literal.

  • @Stelaninja
    @Stelaninja2 жыл бұрын

    Thought I knew the most string methods. But I was wrong! Great video!

  • @patloeber

    @patloeber

    2 жыл бұрын

    haha same for me before creating this video :D

  • @datamaniac2048
    @datamaniac20482 жыл бұрын

    Keep it up!

  • @patloeber

    @patloeber

    2 жыл бұрын

    I will!

  • @higheloguy9057
    @higheloguy90572 жыл бұрын

    how about changing replace method, so you can pass list of strings as 1st argument

  • @ObryanPoyser
    @ObryanPoyser2 жыл бұрын

    Thx!!!

  • @patloeber

    @patloeber

    2 жыл бұрын

    You're welcome!

  • @charleslc1853
    @charleslc18532 жыл бұрын

    it's helpful

  • @patloeber

    @patloeber

    2 жыл бұрын

    thank you!

  • @PrivacyEnt
    @PrivacyEnt Жыл бұрын

    1:56 waitt why it didn't remove the m from example, making it exaple?

  • @kris_maussen
    @kris_maussen2 жыл бұрын

    Is there in python something like stringbuffer /stringbuilder? Correct me if I'm wrong but in Python strings are unmuttable ... not?

  • @justaduckcallednerimo
    @justaduckcallednerimo2 жыл бұрын

    why did the lstrip remove all the way to r (Arthur: three)?

  • @__________________________6910
    @__________________________69102 жыл бұрын

    Nice !

  • @patloeber

    @patloeber

    2 жыл бұрын

    Thanks!

  • @StarFury2
    @StarFury22 жыл бұрын

    Been learning Python for 2 months, watched many great videos, but this is probably the most efficient 10 minutes! Keep up the great work. I know all this is in official documentation, but it's so much better learning with a narrator and examples. I just wish I found this video earlier as it would save me hours of stackoverflow parsing.

  • @cvaldes__

    @cvaldes__

    Жыл бұрын

    Just curious, how far have you come along now that its been almost a year?

  • @StarFury2

    @StarFury2

    Жыл бұрын

    @@cvaldes__ I feel quite confident with python now, stopped watching tutorial videos, and actually focused on creating unique stuff I need for my work. You never stop learning of course, but you become more confident learning from official documentations and start examining python package files you just downloaded, rather than just blindly importing them in your project. I think this is the important milestone telling you've transit from beginner to intermediate user.

  • @cvaldes__

    @cvaldes__

    Жыл бұрын

    @@StarFury2 Thanks for the reply! It inspires confidence just to know that if I stick to it, eventually things should begin to click. I'm currently on my second month as well and struggling with OOP... Any wisdom or tips you can impart on a beginner that maybe helped you as well?

  • @StarFury2

    @StarFury2

    Жыл бұрын

    @@cvaldes__ Yeah, the key is to really stick to it, have patience and spend as much time coding as you can. Progress is slow, but it's also steady. Many would get frustrated and give up, some will push through and it will pay off in the end. OOP gets incredibly useful when you start to work on larger programs, but it's super confusing in the beginning. I watched one OOP tutorial video after another, repeating learning same concepts like attribute, instance, self, method types, inheritance etc. over and over again, giving them time to sink in while practicing using them in my own programs. As time goes by, it becomes more and more about what you want to do, and less about how do you do it.

  • @mrmedbedb1256
    @mrmedbedb12562 жыл бұрын

    Штуки 4 финтов не знал :) А zfill нужен как раз!

  • @eatbreathedatascience9593
    @eatbreathedatascience95932 жыл бұрын

    Thanks.

  • @patloeber

    @patloeber

    2 жыл бұрын

    You're welcome

  • @gorand1018
    @gorand10182 жыл бұрын

    3. zadatak n=int(input('upisi prirodan broj')) r={} for i in range (n): x=input() r.update({len(x):int(x)}) k=list(r.keys()) k.sort() g={} for i in k: g.update({i:r[i]}) print(i,g[i])

  • @Juanjo-do4qz
    @Juanjo-do4qz2 жыл бұрын

    El mejor video

  • @dominion2734
    @dominion27342 жыл бұрын

    Ehre!

  • @saintelohim
    @saintelohim Жыл бұрын

    1:57 why the m in example is still there?

  • @x7.

    @x7.

    Жыл бұрын

    Didn't notice that lol, did you find an answer ?

  • @hackingdevice7953
    @hackingdevice79532 жыл бұрын

    Simply useful... Just need to memorize the name of methods😂

  • @facundogoiriz7323
    @facundogoiriz73232 жыл бұрын

    strip and replace

  • @XAUGoblin
    @XAUGoblin Жыл бұрын

    Which methods are the most useful and used in coding very frequently? I am a newbie in coding and I want to understand and memorize the functionality of the most important string methods among all the methods mentioned in the video.

  • @gorand1018
    @gorand10182 жыл бұрын

    1. zadatak s=input() k=s.split()#stavljamo svaku rijec iz stringa u listu i brojimo koliko clanova print(len(k))#ima lista s=s.replace('a','')#izbrise sve a iz stringa i umjesto njih doda nista print(s) br=0 for i in s: if i.isupper(): #metoda pomocu koje gledamo jeli to slovo veliko slovo br=br+1 print('ovoliko je velikih rijeci u stringu', br) r={} for i in k: r.update({len(i):i}) #za svaku rijec u listi k gledamo koliko ima slova print(r)#pomocu len(i)

  • @zsoltbr
    @zsoltbr2 жыл бұрын

    'This' must be his favorite word.

  • @riskzerobeatz
    @riskzerobeatz2 жыл бұрын

    Very useful if you're too lazy to go through the docs yourself :D

  • @patloeber

    @patloeber

    2 жыл бұрын

    Very true!

  • @therabidpancake1
    @therabidpancake1 Жыл бұрын

    So you are saying that there are a limited number of strings that tha we nan use in Python ? You just showed us 31

  • @AhadAli-bb3xj
    @AhadAli-bb3xj2 жыл бұрын

    Such a perfect timing....preparing for tomorrow's python exam 😅😅

  • @patloeber

    @patloeber

    2 жыл бұрын

    Good luck!!

  • @ramupoonjolai9974
    @ramupoonjolai99742 жыл бұрын

    Hi, you are doing good. One suggestion to you. You need to give a moment break between sentences. Since you continuously talk from beginning to end of video, i have to go foreward backward to understand you completely. If you emphasize on certain point, give a second break so we can get it and going. Otherwise your videos are very informative.

  • @patloeber

    @patloeber

    2 жыл бұрын

    Thanks for the feedback! I try to improve this next time

  • @skl9942

    @skl9942

    2 жыл бұрын

    I don't agree, I really enjoy the fast-paced style.

  • @patloeber

    @patloeber

    2 жыл бұрын

    @@skl9942 good to know :) seems like a lot of people enjoy the fast paces style...Probably there is not the perfect pace for everybody...

  • @greenhoodie

    @greenhoodie

    2 жыл бұрын

    Fast paced is good. The pause button is there. It also shows you respect time by not fluffing it out 👍 Awesome video.

  • @franky12

    @franky12

    2 жыл бұрын

    I also like the fast pace!!! There are so many youtube tutorials that are so incredibly slow and boring...

  • @brightaneva6282
    @brightaneva62822 жыл бұрын

    First in comment

  • @patloeber

    @patloeber

    2 жыл бұрын

    yeah

  • @yavuzselimikizler814
    @yavuzselimikizler8142 жыл бұрын

    Sj

  • @maybenew7293
    @maybenew72932 жыл бұрын

    man, breathe