Python ProgrammingPython Programming

How to get specific key value from list of dictionary in Python?

thedict = [{"key": 1, "prog": 'Python'},
           {"key": 2, "prog": 'Java'},
           {"key": 3, "prog": 'Php'}]

thelist = [thelist['key'] for thelist in thedict if 'key' in thelist]
print(thelist)

thelist = [thelist['prog'] for thelist in thedict if 'key' in thelist]
print(thelist)
Output
[1, 2, 3]
['Python', 'Java', 'Php']