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

MRAB python at mrabarnett.plus.com
Sun Nov 19 14:32:04 EST 2017


On 2017-11-19 19:03, Ben Finney wrote:
> 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?
> 
The function itself is called 'correctAnswers', and a function is never 
equal to a string.



More information about the Python-list mailing list