substring
A run of consecutive characters inside a longer string, such as "ssi" in "Mississippi".
In more detail
You can test for one with in, find where it starts with find, count occurrences with count and extract one with a slice. Substrings are always new strings; extracting one never changes the original.
Related terms
- slice — A copy of a run of items from a string, list or tuple, written s[start:stop], which includes start and stops just before stop.
- find() — A string method that returns the index where a substring first appears, or -1 if it does not appear.
- in operator — The operator that tests whether a value is contained in a string, list, tuple, set or dictionary, giving True or False.
Taught in
- Objects, Methods And String Case — Hands-on Python: Complete Video Course & Book
- String Slices — Hands-on Python: Complete Video Course & Book
- Mad Libs Revisited: The Whole Program — Hands-on Python: Complete Video Course & Book
- Chapter Two In One Sitting — 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
- Strings Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep