What is wrong with this code? Please tell me


#1

Hi,
I was practicing by writing my own code in the editor in the chapter 'Go with the flow'. The following piece is working okay if I put an option "tea" or "coffee". But if I simply put enter as response without choosing either of the two, the code is not taking any input. Please help me.

 def home():
    print "You are home." 
    print "Would you like to have some tea or coffee?"
home()    

answer = raw_input("Type tea or coffee.")
 
if answer == "tea" or answer == "t":
    print"Thank you for your response. Tea is on its way."
 
elif answer == "coffee" or answer == "c":
    print"Thank you for your response. Coffee is on its way."
 
else:
    print"Please type Tea or Coffee to refresh yourself."
    home()

#2

only the function runs again when there is invalid input, so then you would need to place everything inside the function


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.