I have some code that prints data from a global dictionary named cal
:
def show_todo():
for key, value in cal.items():
print(value[0], key)
However, I want to use this code as part of a Discord bot. In order for the bot to work properly, I need to return
the data to another function that will actually send the message to the Discord chat. Using print
like above means that the message is displayed in my local console window, and the chat just sees None
.
I tried to fix it by using return
instead:
def show_todo():
for key, value in cal.items():
return(value[0], key)
but this way, the for loop does not work properly. I only get at most one key-value pair from the dictionary.
How can I fix this so that all of the data is returned?