Challenge
Index by ID
…six items, but the real manifest has thousands. Build an index from ID to record once, then answer the questions from it. Build the index Build a dict called by_id that maps each cargo ID to its…
Showing 1–10 of 41
Challenge
…six items, but the real manifest has thousands. Build an index from ID to record once, then answer the questions from it. Build the index Build a dict called by_id that maps each cargo ID to its…
Challenge
readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.
Example
Tuples have only two methods: count() for counting and index() for searching.
Example
Accessing list elements by index. Changing and removing elements.
Example
…individual characters and text fragments. Zero-based indexing in Python.
Challenge
…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
…Commander: Okafor Newest member: Kowalska Crew size: 4 Indexes start at 0, as in strings. crew[-1] is the last item whatever the list's length, and len(crew) counts the items. The whole roster Add the…
Challenge
…five bugs: a syntax error, a type error, a wrong key, an index out of range and a reversed decision. Read each error to fix the four that crash, then find the one that runs but gives the wrong answer.
Quiz
…errors to read and fix – NameError, TypeError, ValueError, IndexError, KeyError, IndentationError and ZeroDivisionError.
Quiz
…beginner quiz on Python strings: 15 questions on joining, indexing, slicing, len(), split(), join() and string methods, with instant answers.