xxxxxxxxxx
#python 3
for k,v in dict.items():
print(k, v)
xxxxxxxxxx
# Dictionary
dict1 = {1:'A', 2:'B', 3:'C'}
# List of the keys
keysList = list(dict1.keys())
print(keysList)
# List of the values
valuesList = list(dict1.values())
print(valuesList)
xxxxxxxxxx
#!/usr/bin/python3
a = {"a":"b","c":"d"}
a_values = list(a.values())
print(a_values)
# output: ["b", "d"]
xxxxxxxxxx
hh = {"a":3, "b":4, "c":5}
print(hh.keys())
# dict_keys(['a', 'b', 'c'])
print(list(hh.keys()))
# ['a', 'b', 'c']
xxxxxxxxxx
#dictionariies
programming = {
"Bugs": "These are the places of code which dose not let your program run successfully"
,"Functions":"This is a block in which you put a peice of code"
,"Shell":"This is a place where the code is exicuted"
}
print(programming["Bugs"])
print(programming["Shell"])
for eliment in programming:
print(eliments)
xxxxxxxxxx
my_dict = {"name": "John", "age": 25, "occupation": "Developer"}
# Using the keys() method to get all keys from the dictionary
keys = my_dict.keys()
# Converting the keys into a list
key_list = list(keys)
# Printing the list of keys
print(key_list)