Example
String Indexing and Slicing
Accessing individual characters and text fragments. Zero-based indexing in Python.
Showing 1–10 of 14
Example
Accessing individual characters and text fragments. Zero-based indexing in Python.
Quiz
…quiz on Python strings: 15 questions on joining, indexing, slicing, len(), split(), join() and string methods, with instant answers.
Quiz
…beginner quiz on Python lists: 15 questions on indexing, slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Challenge
…last four characters of an access code with * using len(), slicing and string repetition, then find a code inside a log line and mask it there before the line is saved.
Challenge
Show only the five most recent CO2 readings with the slice [-5:], as a dashboard does, then add a new reading and print how much the level changed across the window.
Challenge
Slice the date and the time of day out of an ISO timestamp like 2026-03-14T09:30:05Z, then rebuild it in the day.month.year format used in Poland and much of Europe.
Challenge
A slice meant to take the number from the container tag CG-0042 gives -004. Predict it, work out where indexes start and where a slice ends, fix it, then slice a sample label yourself.
Challenge
Check whether a mission log line contains ERROR with in, find where it starts with find(), including the -1 it gives when there is nothing to find, then slice out the error message.
Challenge
code[0] = "X" stops with a TypeError, because Python strings can't be changed. Predict the crash, find out what methods and slices really give, build a new string instead, then swap a letter in the…
Challenge
Extend the parser from "Parse a telemetry line" to read three readings from a multi-line feed, print each as one row, then turn them into a report with a header and aligned columns.