I am trying to reverse a dictionary by flipping the values with the keys
The output i got: {3: 'love', 2: 'self.py!'}
the output I want: {3: ['I', 'love'], 2: ['self.py']}
my code:
def inverse_dict(my_dict):
inv_dict = {v: k for k, v in my_dict.items()}
print(inv_dict)
def main():
course_dict = {'I': 3, 'love': 3, 'self.py!': 2}
inverse_dict(course_dict)
if __name__ == "__main__":
main()
It's like took away the key and the value 'I': 3 someone knows why?