[Tutor] why does this not work

Dave Angel davea at davea.name
Wed Apr 24 04:47:38 CEST 2013


On 04/23/2013 03:39 PM, Roelof Wobben wrote:
> Im trying to learn python by a course at codeacademy. Now I have this code : def shut_down(s):
>      s = s.lower()
>      if s == "yes":
>          return "Shutting down..."
>      elif s == "no" :
>          return "Shutdown aborted!"
>      else:
>          return "Sorry, I didn't understand you"
>      But when I run it  I see this message: It looks like output other than yes/no does not return
> "Sorry, I didn't understand you." So can anyone explain to me what I did wrong. Roelof  		 	   		
>

Wrong?
1) your message is in html, not text.  So the formatting is messy.  It 
could have been worse, so please learn how to make your email program 
behave.
2) You didn't show your whole program.  If this is all you have in the 
file, then nothing will print because nothing calls your function.
3) You didn't describe your environment, including python version & OS. 
  And if Oscar's conjecture is correct, all bets are off because most of 
us won't be familiar with the strange environment.
4) I can't see how you could possibly get the message:
'It looks like output other than yes/no does not return "Sorry, I 
didn\'t understand you."'  And in fact the last part of the message is 
different than the literal in the program, so you've got a typo besides. 
  Please use cut&paste to show your actual code, your actual output.

After reading oscar's comment, my guess is that codeacademy (not Python) 
is complaining about the period at the end of your last literal string.

-- 
DaveA


More information about the Tutor mailing list