Code Labs: Data Structures
Put Arrays, Indexing, and 2D Matrices into practice.
Interactive Engine
Use the interactive terminal below to test Python Lists (1D Arrays).
User Input Required
The Crucible
Prove your knowledge of arrays and indexing.
The Precise Extraction
You have an RPG inventory array: ["Sword", "Shield", "Potion", "Map"]. Remember that counting strictly starts at 0.
Task: Use square brackets [] to extract and print exactly the word "Potion".
Overwriting Data
Arrays are mutable (they can be changed). We need to fix a corrupted database score.
Task: Without deleting the array creation line, overwrite the very first score in the array so it equals 99 instead of 10.
The Database Matrix
A 2D Array is just an array inside another array. To access it, you need TWO indexes: database[Row][Column].
Task: Look at the 2D array below (it represents a database table of usernames and passwords). Use 2D indexing to print the username "Admin".