Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to Create a Dictionary in Python
- Dictionaries are made up of key and value pairs nested in curly brackets. Here's an example of a Dictionary:
- devBio = {
- "name": "Ihechikara",
- "age": 120,
- "language": "JavaScript"
- }
- print(devBio)
- # {'name': 'Ihechikara', 'age': 120, 'language': 'JavaScript'}
- In the code above, we created a dictionary called devBio with information about a developer – the developer's age is quite overwhelming.
- Each key in the dictionary – name, age and language – has a corresponding value. A comma separates each key and value pair from another. Omitting the comma throws an error your way.
- Before we dive into how we can add items to our dictionaries, let's have a look at some of the features of a dictionary. This will help you easily distinguish them from other data structures in Python.
- FOR MORE:https://usdshort.com/WxSZzdDq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement