String Slicing and Concatenation
Master slicing syntax and combining strings.
Introduction
Slicing extracts a substring using [start:stop:step] syntax. Concatenation joins strings together.
Basic Slicing
s[1:4] returns characters at indices 1, 2, 3 — stop is exclusive. s = 'Python'; s[1:4] is 'yth'.
s = 'Python'
print(s[1:4])All lessons in this course
- String Basics and Indexing
- String Slicing and Concatenation
- Common String Methods
- String Formatting with f-strings