Quote:1 def dictKeysOnly (dictionary):
----> 2 lst = [{dictionary}]
3 lst = sorted(lst)
4 return (lst)
5 print("List in ascending order: ",sorted(dictionary))
This is different from the first code you posted, and as such shows a different error message. Note that the print statement will never be reached if is is indeed under the def.
Quote:What do you mean by it's not defined outside the function
The original message "NameError: name 'dictionary' is not defined" which was likely caused by the print statement not being indented under the function def.