jeudi 6 avril 2017

Python - Can't seem to get return statement to work in simple function?

I have a simple function accessing a dictionary with an if statement.

 langdict = {"english": "Hello, World!", "french":"Bonjour, tout le monde!"}

 def hello(language):
     if language in langdict:
         return langdict[language]
     else:
         return None

Now everything works fine and dandy with print statements obviously. But nothing happens when I use the return statement on both lines 5 and 7. What am I missing?

Aucun commentaire:

Enregistrer un commentaire