Python Basics: Strings and String Methods (Summary)
In this video course, you learned the ins and outs of Python string objects.
You learned how to access different characters in a string using indices
and slices, as well as how to determine the length of a string with len()
.
Strings come with numerous methods. The .upper()
and .lower()
methods convert all characters of a string to uppercase and lowercase,
respectively. The .rstrip()
, .lstrip()
, and .strip()
methods remove
whitespace from strings, and the .startswith()
and .endswith()
methods tell you if a string starts or ends with a given substring.
You also learned how to capture input from a user as a string using the
input()
function, and how to convert that input to a number using int()
and float()
. To convert numbers and other objects to strings, you use
str()
.
Finally, you learned how to use the .find()
and .replace()
methods to find
the location of a substring and replace a substring with a new string.
For more information on the concepts you’ve covered in this course, check out:
- Python 3’s f-strings: An Improved String Formatting Syntax
- Splitting, Concatenating, and Joining Strings in Python
- Reading Input and Writing Output in Python
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 This lesson is a summary and includes additional resources for you to continue your learning. In the course, you learned how to manipulate strings with string methods.
00:11 You learned how to work with user input and deal with strings of numbers. Along with that, you learned a handful of ways to format strings for printing.
00:22 And along the way, you also learned about f-strings, multiline strings, how to index and slice strings, how strings are immutable, and you also learned how to discover additional methods using IDLE.
00:37 Here’s a few additional Real Python video courses for you to learn a little bit more about working with strings. The first is about Python’s f-strings. As you’ve already learned, f-strings are a great way to format strings.
00:51 They’re more concise and less prone to error than other ways of formatting, and they’re also faster.
00:58 The next covers splitting, concatenating, and joining strings in Python.
01:04 And the last video course is a deeper dive into reading input and writing output in Python. Check out the description text below this video for links to these additional resources. I want to say thanks, and congratulations on completing the course.
taniferf on Nov. 5, 2024
This knowledge is very useful.
Become a Member to join the conversation.
nb20pygeek on July 7, 2023
This is good!