Quick actions

cmd+k|ctrl+k

Navigation

Languages

Python_3

Snippet info

Language

Python

Visibility

public

Author

doruk.ayd20

Created

2025-01-02T19:57:23.360616Z

Updated

2025-01-03T13:56:36.178285Z



        #DICTIONARIES -> {'key':value, ... }, unordered key value pair, can store any value types

# dictionary = {'a':[1,2,3] , 'b':'hello', 'x':True}
# print(dictionary['a'][0]) # -> accesing

# my_list = [
#     {
#     'a':[1,2,3], 
#     'b':'hello', 
#     'x':True
#     },
#     {
#     'a':[4,5,6] , 
#     'b':'hello', 
#     'x':True
        
#     }
# ]
# print(my_list[0]['a'][2]) # -> accesing the value of the dict in the list

  #dict keys -> keys msut be immutuable, descriptive, unique

  #dictionary methods
user = {'basket':[1,2,3] , 'greet':'hello', 'age': 20}
 
user2 = dict(name = 'JOJO') # not common way to create a dictionary
#print(user.get('age','25'))


  #dictionary methods2
# print('age' in user.keys())
# print('hello' in user.values()) 
# print(user.items())
#print(user.clear())
# user2 = user.copy()
# print(user2)
# print(user.pop('age'))
# print(user)
print(user.update({'age': 23}))
print(user)
INFO