On 11/10/15 22:22, Nym City wrote:
import urllib2 import jsonlocu_api = 'redacted' ans=True while ans: print (""" 1.Search by City 2.Search by State 3.Search by Zip 4.Exit/Quit """) ans=raw_input("What would you like to do? ") if ans=="1": print("\n Enter City") elif ans=="2": print("\n Search by State") elif ans=="3": print("\n Search by Zip") elif ans=="4": print("\n Goodbye") elif ans !="": print("\n Not Valid Choice Try again")
Note that you never set ans to any false value so it will keep on looping until you do (by entering an empty string). You probably need to use break to exit the loop whenb you get valid input.
# def locu_search(query): # api_key = locu_api # url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key # locality = query.replace(' ', '%20') # final_url = url + '&locality=' + locality + "&category=restaurant"
Note that you should not try to build the query string yourself, there are functions in the standard library that will do most of the work and they will be more reliable than anythong you can write yourself. For example look at the urllib module (for 2.7, its the urlib.parse module in v3) which contains several utility functions such as quote() and urlencode() -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
