Richard Damon wrote: > Cheri Castro wrote: > > I've tried several variations but haven't been able to > > figure out why my final if elif statement won't print. I > > tried using return, I tried using 1's and 0's rather than > > yes and no. Not sure what the issue is. Please, help. > > > > > > #This function will print how many yes answers the user has and a message > > def correctAnswers(job, house, yard, time): > > if correctAnswers == 'yes': > > print ("Congratulations! You should get a puppy!") > > else: > > return "I'm sorry, you shouldn't get a puppy." > > Why does one path print and the other return, those are > different actions.
A valid point. My guess is that the OP may have wanted to explicitly exit the look on this branch (instead of allowing it fall off the end of the function) perhaps because some of the code is missing from example or perhaps because some code may be added in the future as an extension of the if clause. Setting up such a conditional structure such as this allows the intent to be clear. And any incidental code that supports the if clause can be handles after flow falls off the end of the conditional, and returns to the function body. But who knows... However, i'm more concerned that this code unapologetically discriminate against those who'd rather have a kitten! :-( I want a *KITTEN*! And a safe space! -- https://mail.python.org/mailman/listinfo/python-list