Dictionaries
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
#Dictionary
dictionary = {
'a' : [1,2,3],
'b' : 'hello',
'x' : True
}
print(dictionary['b'])
print(dictionary)
my_list = [
{
'a' : [1,2,3],
'b' : 'hello',
'x' : True
},
{
'a' : [1,2,3],
'b' : 'hello',
'x' : True
}
]
print(my_list [1] ['b'] [0:5])
dictionary = {
'weapons' : [1,2,3],
'greeting' : 'hello',
'is_magic' : True
}
dictionary = {
'basket' : [1,2,3],
'greet' : 'hello'
}
print(dictionary ['basket'])
user = {
'basket' : [1,2,3],
'greet' : 'hello',
'age' : 20
}
print('basket' in user)
user2 = {
'basket' : [1,2,3],
'greet' : 'hello',
'age' : 20
}
print(20 in user2.keys())
user3 = {
'basket' : [1,2,3],
'greet' : 'hello',
'age' : 20
}
print(20 in user3.values())
Python
INFO