In this python dictionary, we will create a flat list of all the values 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 values of the dictionary.
- Add the values to the list using the append() function.
- Print the output.
D1 = {'sqa':1,'tools':2,'is':3,'best':4}
l = []
for k in D1.values():
l.append(k)
print(l)
Output :
[1, 2, 3, 4]