mercredi 21 décembre 2016

Python Basic If Statement

def main_loop():

  print "where are you from?"
  loc = raw_input()

  print "so your from " + loc + "?"
  ans = raw_input()


def isittrue():
  if ans == "yes":
    print "We all love " + loc
  else:
    print "Where did you say you were from again?"


main_loop()    
isittrue()

Im trying to create a script that will prompt the user for their location, ask them to confirm the location, if the location is confirmed to then display a message, otherwise start the script again.

However keep getting the following error: NameError: name 'ans' is not defined on line 18 in main.py

Any advice is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire