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 trialJoseph Michelini
Python Development Techdegree Graduate 18,692 PointsHow does the not ! operator know if the outcome of checkForWin() is true or false?
I understand that inside checkForWin()
there is a variable called win
that starts out false and changes to true under certain conditions, but without the function explicitly returning the value of win, how does the !
operator know to check the win
variable specifically? What if I had more than one variable with a boolean value in the function?
I'm asking specifically because I'm wondering how I can use the !
operator with other functions, and what kind of information is being implicitly read and returned here for the !
operator to act on.
Thank you!
1 Answer
Steven Parker
231,271 PointsThe function does return the value explicitly. The very last statement of the function shown in the instruction is:
return win;
Joseph Michelini
Python Development Techdegree Graduate 18,692 PointsJoseph Michelini
Python Development Techdegree Graduate 18,692 PointsOh man it most definitely does. I was a little lost in the program and somehow missed exactly what I was looking for. Sort of like looking for your keys when you're trying to leave the house. Thank you Steven!