0

I'd like to be able to use raw_input put in by the user in an if statement, but I have no idea how to do it. Here, I ask them for raw input and if they type, "yes", I want to print, "Your triangle is:". if they type, "no", I want to print "Thank you for your time." Is there a way to do this? Please see my code below:

tri=raw_input("Do the points that you entered form a triangle? (yes or no)")  
tri=str(tri)  

if tri == "yes" or "Yes" or "YES":   
    print "Your triangle is an:"  
elif tri == "no" or "NO" or "No":  
    print "Thank you for your time."  
else:  
    print "Not a valid answer, please try again later."

Also, if the user types "no", I want to end all code after that. Is there some way of putting that into the elif part of the if statement? (Note: I will write a function after this if statement, but I only want the function to work if the user types "yes".)

This is different from other questions on this site because I'm asking for raw_input.

  • This is not the same question as the one you listed @TigerhawkT3 – Zach Erickson May 02 '16 at 00:32
  • 1
    That doesn't make the slightest difference. Please read the answers on the linked duplicate. – TigerhawkT3 May 02 '16 at 00:35
  • @TigerhawkT3 how do I stop the code so that the function I will write after that doesn't run? In addition, in my code should I put quotation marks around the `yes` or `no` if I want to include the raw_input put in by the user? – Zach Erickson May 02 '16 at 00:43
  • 1
    Functions already don't run unless you call them. You should put quotation marks around any characters you want treated as a string literal. It sounds like you would benefit from looking over the [official Python tutorial](https://docs.python.org/3.5/tutorial/index.html). – TigerhawkT3 May 02 '16 at 00:45

0 Answers0