string method
A method that belongs to strings, such as upper, lower, count, find, replace, split, strip, startswith or join.
In more detail
Strings are immutable, so string methods never change the original; they return a new string, or a number, list or Boolean. dir(str) lists them all and help(str.find) explains one.
Related terms
- string — A sequence of characters, that is, a piece of text.
- method — A function that belongs to an object or type and is called on a value of it, as in name.upper().
- upper() and lower() — String methods that return a copy of a string in capitals or in small letters.
- find() — A string method that returns the index where a substring first appears, or -1 if it does not appear.
- split() — A string method that cuts a string into a list of parts, at white space by default or at a separator you give.
Taught in
- Objects, Methods And String Case — Hands-on Python: Complete Video Course & Book
- String Slices — Hands-on Python: Complete Video Course & Book
- Split And Join — Hands-on Python: Complete Video Course & Book
- More String Methods — Hands-on Python: Complete Video Course & Book
- Strings: Escapes, Slices And Methods — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Comparing, Slicing And Never Changing — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- String Methods The Exam Picks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep