So, I need to print the sales of my hotel management system both in ascending and descending order. I found these codes down below which solved my problem (yes, I'm a total beginner).
def ascend(self, dict):
print({k: v for k, v in sorted(dict.items(), key=lambda item: item[1])})
def descend(self, dict):
print({k: v for k, v in sorted(dict.items(), key=lambda item: item[1], reverse=True)})
It does print out the sales but the output has a single quote around the key, curly braces, and only in one line which is the total opposite of my desired output. How do I sort in ascending and descending while printing each in a new line without the curly braces and the single quote?
Big thanks to anyone who could help!