50. Dictionnary Flashcards
1
Q
what is a dict?
A
- it is a data structure ( a way to organize data)
2
Q
how can you organize data with dict ?
A
name = {
‘key’ : value,
}
print(name[‘b’’])
it prints the value
name is used as dictionary
3
Q
A dictionary can be___.
A
scattered
4
Q
what are it’s benefits vs a list?
A
- you can use boleans, strings, and lists :), and assign them to a letter
- ## ‘a’:…..
5
Q
how do you print the first line of the code if it looks something like this:
my_list = [
{
‘a’: [1,2,3]
‘b’: ‘hello’,
},
{
‘a’: [4,5,6],
‘b’: ‘hello’,
‘x’: True
}
]
A
print(my_list[0] [‘a’][2])
this means that
0 is the first item, ‘a’ is the key, and 2 is the second key