'Python for Everybody' Chapter 13 - Using Web Services (Solved Exercises)

preview_player
Показать описание

Here is the code for the solutions:

Make sure to check out my other tutorial series on Django:

Follow me on
Рекомендации по теме
Комментарии
Автор

Thanks so much man, I can usually dissect the answers from the code but for this exercise I couldn't figure anything out. This was extremely helpful!

brianjohnson
Автор

Code works for the most part. However if you tried looking for Ireland, it does not work. The code I came up with will returns all country code

country_code = 'Not found'
results = js['results']
for i in results:
for k in i['address_components']:
if 'country' in k['types']:
country_code = k['short_name']
print('Country Code:', country_code)

omgicantthinkofaname
Автор

Thank you for this help! One problem though: the Try/Except does not work for this. When entering "Atlantic Ocean" as the location, it returns "Country Code: Atlantic Ocean" instead of the "Country Code not found" message. Any suggestions?

dmnirican
Автор

I'm getting str object not callable error while running the original program from the book.

Khanarmaanrokz
Автор

can someone explain me this little code please?
if not js or 'status' not in js or js['status'] != 'OK':.

ManuelGutierrez-dceb
Автор

May I ask which program do you use to execute the code ?

xuancong
join shbcf.ru