Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Dantee Fluellen
1,499 PointsReturn statement is not printing.
""" A Functional Breakfast """ def mix_and_cook(): print('Mixing the ingredients') print('Pouring the mixture into a frying pan') print('Cooking the first side') print('Flipping it!') print('Cooking the other side')
def make_omelette(ingredient): mix_and_cook() omelette = 'a {} omelette'.format(ingredient) return omelette
def make_pancake(): mix_and_cook() pancake = "a delicious pancake" return(pancake)
make_omelette('bacon')
why isn't my return statement not printing out.
1 Answer
Pedro Cabral
33,586 Points- You call make_omelette('bacon')
- The code inside make_omellete(ingredient) runs and calls mix_and_cook() and outputs all the print messages.
- You create a string a bacon omelette' and return it.
- Back on your make_pancake() the first method just run mix_and_cook() however, you didn't catch the return statement (the string created on step #3) and you are therefore losing that output.
- You are further creating another string "a delicious pancake", assigning it to a variable called pancake and returning it, but you are also not doing anything with that return value which also gets lost in turn.
Side note: return statements don't get printed on their own, unless you invoke the print() function. Return, simply gives back the value(s) back to the caller.
Dantee Fluellen
1,499 PointsDantee Fluellen
1,499 Pointsyeah thanks i found that out. the video i on linkin learning i was following i forgot that he was in the python shell and not the ide. (Is it called an ide?)
rydavim
18,814 Pointsrydavim
18,814 PointsDantee Fluellen - If Pedro Cabral answered your question, please consider voting on it or marking it best answer. This encourages community, and let's other students know that your problem has been solved. Happy coding!