April 2024
Beginner to intermediate
500 pages
24h 20m
English
Python has three sequential data types: strings, lists, and tuples. Table B.4 summarizes the operators that apply to all sequences.
Table B.4 Operations on Any Sequence in Python
| Operation | Operator | Explanation |
|---|---|---|
| Indexing | [n] | Accesses the nth element of a sequence. |
| Concatenation | + | Combines sequences. |
| Repetition | * | Concatenates a repeated number of times. |
| Membership | in | Returns True if an item is in a sequence; False otherwise. |
| Membership | not in | Returns True if an item is not in a sequence; False otherwise. |
| Slicing | [ : ] | Extracts a part of a sequence. |
Strings are immutable sequences of characters that are indexed by integers, starting at zero. To create string literals, you can enclose them ...
Read now
Unlock full access