Page 1 of 1

Python: Slicing - # 2

Posted: Sat Oct 25, 2025 4:34 pm
by The Jason

Code: Select all

band_name = "Shocking Blue"

print(band_name[ : : 2])

# Going thru the whole string and skipping every letter so outputting the letters: "S", "o", "k", "n", "B", and "u"

band_name = "The Monkees"

print(band__name[2 : 7 : 3])

# Starting at index 2 which is "e", skipping every 2nd letter until the index 7 which is also "e", so that "n" is displayed.