Skip to content

Commit 116dbdc

Browse files
committed
Intro about Dictionary
1 parent c7d20b7 commit 116dbdc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Each key is separated from its value by a colon (:), the items are separated by commas, and the whole thing is enclosed in curly braces. An empty dictionary without any items is written with just two curly braces, like this: {}.
2+
# Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.
3+
4+
# How to create a dictionary with some values?
5+
6+
myDict = {'name': 'AnyName', 'id': 123, 'info': 'value of id not neccessarily need to be string since it has integer as numbers'}
7+
8+
print(myDict) # Output: {'name': 'AnyName', 'id': 123, 'info': 'value of id not neccessarily need to be string since it has integer as numbers'}
9+
10+
print(myDict.keys()) #Output: dict_keys(['name', 'id', 'info'])

0 commit comments

Comments
 (0)