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
3:09 Just a note that removeprefix and removesuffix are only available in 3.9 or later.
Great run-through. Will definitely watch again before starting a string-heavy project.
this is great content and format, please bring us more of this kinda summary !!
@dilyornematjon1526
2 жыл бұрын
asd
Great format. Super useful!
Thanks for the examples!
Great job! To the point and useful.
@patloeber
2 жыл бұрын
Glad you think so!
Awesome! Thank you for the great content!
This is really cool bro. Please make more such useful summaries. Thank you
@patloeber
2 жыл бұрын
Thanks, will do!
Thanks for this, so useful
Great video, helped me a lot :)
awesome content for a beginner!!!
It is very useful as my quick reference of string methods, thanks.
@patloeber
2 жыл бұрын
Glad it was helpful!
Great video! I loved the tips, they are very useful!
@patloeber
2 жыл бұрын
Glad you like them!
@dilyornematjon1526
2 жыл бұрын
bullshit video
Thank you, some of the methods were unknown to me
Thank you for the video
this is extremely good content
Thanks . I knew everyone of it 😁😁
very goog video , i learned a lot , thanks
ty we need more :)
fantastic!
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... 😄😄😄
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
2 жыл бұрын
Because the strip method only works for characters located at the beginning or at the end of a string
awesome sir
Just Awesome❤❤❤❤❤❤❤❤
Great video!!! 😀👍
@patloeber
2 жыл бұрын
Thank you! 😀
Lots of love
tnx
Thanks,
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.
Thought I knew the most string methods. But I was wrong! Great video!
@patloeber
2 жыл бұрын
haha same for me before creating this video :D
Keep it up!
@patloeber
2 жыл бұрын
I will!
how about changing replace method, so you can pass list of strings as 1st argument
Thx!!!
@patloeber
2 жыл бұрын
You're welcome!
it's helpful
@patloeber
2 жыл бұрын
thank you!
1:56 waitt why it didn't remove the m from example, making it exaple?
Is there in python something like stringbuffer /stringbuilder? Correct me if I'm wrong but in Python strings are unmuttable ... not?
why did the lstrip remove all the way to r (Arthur: three)?
Nice !
@patloeber
2 жыл бұрын
Thanks!
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__
Жыл бұрын
Just curious, how far have you come along now that its been almost a year?
@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__
Жыл бұрын
@@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
Жыл бұрын
@@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.
Штуки 4 финтов не знал :) А zfill нужен как раз!
Thanks.
@patloeber
2 жыл бұрын
You're welcome
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])
El mejor video
Ehre!
1:57 why the m in example is still there?
@x7.
Жыл бұрын
Didn't notice that lol, did you find an answer ?
Simply useful... Just need to memorize the name of methods😂
strip and replace
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.
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)
'This' must be his favorite word.
Very useful if you're too lazy to go through the docs yourself :D
@patloeber
2 жыл бұрын
Very true!
So you are saying that there are a limited number of strings that tha we nan use in Python ? You just showed us 31
Such a perfect timing....preparing for tomorrow's python exam 😅😅
@patloeber
2 жыл бұрын
Good luck!!
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
2 жыл бұрын
Thanks for the feedback! I try to improve this next time
@skl9942
2 жыл бұрын
I don't agree, I really enjoy the fast-paced style.
@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
2 жыл бұрын
Fast paced is good. The pause button is there. It also shows you respect time by not fluffing it out 👍 Awesome video.
@franky12
2 жыл бұрын
I also like the fast pace!!! There are so many youtube tutorials that are so incredibly slow and boring...
First in comment
@patloeber
2 жыл бұрын
yeah
Sj
man, breathe