'What syntax does this for loop that reverses the key value follow in Python? [duplicate]
dict_list={"a":1,"b":2,"c":3}
inverse_dict=dict([val,key] for key,val in dict_list.items())
The for loop statements I have learned all start with for. I don't understand why there is a list before the keyword for in this statement, and I don't know how this statement can reverse the key-value pairs of the dictionary.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
