In this python dictionary program, we will create a flat list of all the keys in a flat dictionary.
Steps to solve the program
- Take a dictionary as input and create an empty list.
- Use for loop to iterate over keys of the dictionary.
- Add the keys to the list using the append() function.
- Print the output.
D1 = {'sqa':[1,2,5,6],'tools':[3,8,9],'is':[2,5,0],'best':[3,6,8]}
l = []
for k in D1.keys():
l.append(k)
print(l)
Output :
['sqa', 'tools', 'is', 'best']