Student can't get if elif final statement to print for discussion post for python

Ben Finney ben+python at benfinney.id.au
Sun Nov 19 14:03:17 EST 2017


Cheri Castro <blueyes7175 at gmail.com> writes:

> I've tried several variations but haven't been able to figure out why
> my final if elif statement won't print.

The code you presented here does not have any ‘elif’ clause. Did you
mean to show different code?

> 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.

Your questions are welcome here, but you may also be interested in
<URL:http://mail.python.org/mailman/listinfo/tutor> the “tutor”
discussion forum especially for Python beginners.

> #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."

The ‘if’ clause tests the value of ‘correctAnswers’. Where do you expect
that value to come from? Nothing in the function ever sets a value to
that name.

On the other hand, the function never makes use of ‘job’, ‘house’,
‘yard’, or ‘time’. Why are those parameters to the function?

-- 
 \         “How wonderful that we have met with a paradox. Now we have |
  `\                        some hope of making progress.” —Niels Bohr |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list