In the previous levels, we used lists to store items in a specific order. But sometimes, we want to label our data. In Level 13, we introduce DICTIONARIES. At FLORA WORLD CODING, we explain dictionaries as a collection of "Key-Value Pairs." Think of a real-life dictionary: the "word" is the key, and the "definition" is the value. This allows you to look up information instantly without searching through a whole list.
The syntax for a dictionary uses curly brackets {}. For example, if you wanted to store a player's stats in a game, you could create a dictionary where "Health" is 100 and "Level" is 5. By calling player["Health"], Python will immediately give you the number 100. This is significantly faster and more organized than using multiple lists to track related information.
Why is this critical for high-quality, informative coding sites? Dictionaries are the foundation of JSON, which is the language of the internet. Every time you check the weather on your phone or see a social media profile, that data is being sent to you in a format exactly like a Python dictionary. Mastering this concept means you are learning how modern web applications communicate and store user information across the globe.
CREATE A DICTIONARY CALLED MY_PLANT. GIVE IT THREE KEYS: "NAME", "TYPE", AND "HEIGHT". PRINT THE NAME OF YOUR PLANT BY ACCESSING THE KEY. THEN, TRY CHANGING THE HEIGHT VALUE AND PRINT THE DICTIONARY AGAIN!