Skip to content

Commit b13d468

Browse files
committed
Fix syntax highlighting for dict section
Adding extra blank lines to enable syntax highlighting
1 parent f5dcfef commit b13d468

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

python_introduction/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,14 @@ You can find a list of all available list methods in this chapter of the Python
204204
## Dictionaries
205205

206206
A dictionary is similar to a list, but you access values by looking up a key instead of an index. A key can be any string or number. The syntax to define a dictionary is:
207+
207208
>>> {}
208209
{}
209210

210211
This shows that you just created an empty dictionary. Hurray!
211212

212213
Now, try writing the following command:
214+
213215
>>> django_dolls = {'Dottie' : 15, 'Lottie' : 305, 'EmmyLou' : 17}
214216

215217
Don't be surprised with the weird names. Go to the link: http://hubpages.com/hub/50-Doll-Names to look for more cute doll names. :P Just Kidding (You should do this if and only if you have a lot of time).
@@ -222,9 +224,11 @@ When to use a dictionary or a list? Well, a good point to ponder on. Just have a
222224
- Do you need to associate values with keys, so you can look them up efficiently (by key) later on? Use a dictionary.
223225

224226
Dictionaries are mutable like "lists" meaning that they can be changed after they are created. You can add new key/value pairs to the dictionary after it is created, like:
227+
225228
>>> django_dolls['Jilly'] = 67
226229

227230
Like the lists, using len() method on the dictionaries, returns the number of key-value pairs in the dictionary. Go ahead and type in the command:
231+
228232
>>> len(django_dolls)
229233
4
230234

@@ -239,6 +243,7 @@ You can use del() command to delete an item in the dictionary which has particul
239243
As you can see from the output, the key-value pair corresponding to 'Dottie' key has been deleted.
240244

241245
Apart from this, you can also change a value associated with an already created key in the dictionary. Type:
246+
242247
>>> django_dolls['Jilly'] = 100
243248
>>> django_dolls
244249
{'Jilly': 100, 'EmmyLou': 17, 'Lottie': 305}

0 commit comments

Comments
 (0)