Reversing Strings in Python (Summary)
Reversing and working with strings in reverse order can be a common task in programming. Python provides a set of tools and techniques that can help you perform string reversal quickly and efficiently. In this video course, you learned about those tools and techniques and how to take advantage of them in your string processing challenges.
In this video course, you learned how to:
- Quickly build reversed strings through slicing
- Create reversed copies of existing strings using
reversed()
and.join()
- Use iteration to create reversed strings by hand
Even though this topic might not have many exciting use cases by itself, understanding how to reverse strings can be useful in coding interviews for entry-level positions. You’ll also find that mastering the different ways to reverse a string can help you really conceptualize the immutability of strings in Python, which is a notable feature of the language.
For further investigation, check out:
- 📰 Efficient String Concatenation in Python
- 📰 Reverse Python Lists: Beyond
.reverse()
andreversed()
- 📰 Python’s Mutable vs Immutable Types: What’s the Difference?
- 📰 Python
while
Loops (Indefinite Iteration) - 🎬 Mastering
while
Loops - 📰 Python “for” Loops (Definite Iteration)
- 🎬
for
Loops in Python (Definite Iteration)
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
Congratulations, you’ve made it to the final lesson of the Reversing Strings in Python course. In this course, you learned how to reverse strings using slices and the index operator, reverse strings using the reversed()
built-in function, and how to write your very own string reversal algorithm.
00:18 Here are a few Real Python resources for you to explore. The first is Efficient String Concatenation in Python. In this course, you’ll learn how to efficiently concatenate strings in a few different ways.
00:30 The second one is Reverse Python Lists. This course will cover similar topics to the Reversing Strings course, but discusses many of these topics in more depth and gives you more exposure to sequence-type reversal techniques.
00:45 Another great course is Python Mutable vs Immutable Types. While mutability was briefly mentioned in the Reversing Strings course, this course goes into a great deal of depth, teaching you all you need to know about mutability in Python.
01:01
The custom algorithm lesson of the Reversing Strings course leveraged while
loops. These two following courses will teach you Python while
loops and for
loops.
01:09
These will allow you to dive into while
and for
loops without additional distractions. I
01:16 hope you join us again for more courses at realpython.com. Have fun reversing all the strings. If you like, you can expand and modify the custom algorithm from the previous lesson and comment it down below.
Become a Member to join the conversation.