![]() |
print output none - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: print output none (/thread-35428.html) |
print output none - 3lnyn0 - Nov-01-2021 Hi! I have an json (I will attach photo) and I want to extract from it a dictionary e.g. {name: [longitude, longitude]} import json tags = {} coordonate = {} dictionar_coordonate = {} with open('json_generat.json') as f: data = json.load(f) def get_names(data): lista_nume = [] for el in data: lista_nume.append(el['name']) return lista_nume def get_coordonate(name): lista_coordonate = [] for el in data: if el['name'] == name: lista_coordonate.extend([el['latitude'],el['longitude']]) [u]-> the list is created[/u] break def get_latitude_longitude(): global dictionar_coordonate names = get_names(data) for name in names: dictionar_coordonate[name] = get_coordonate(name) -> [u]when I get here the output is {'name': None, ...}[/u] def afiseaza(): for name in dictionar_coordonate.keys(): print('#'*50) print('*'*10, 'Tags of', name, '*'*10) print('-'*50) print(', '.join(dictionar_coordonate[name])) print('-'*50) def start(): get_tags() afiseaza() get_latitude_longitude() start() RE: print output none - deanhystad - Nov-01-2021 Please take down the thumbnail. You shouldn't post addresses and phone numbers. It is also harder to test json code without a json file. Make a fake json file for testing and post that along with your code. RE: print output none - 3lnyn0 - Nov-01-2021 (Nov-01-2021, 08:10 PM)deanhystad Wrote: Please take down the thumbnail. You shouldn't post addresses and phone numbers. It is also harder to test json code without a json phone. Make a fake json file for testing and post that along with your code.it's a fake one, it's random generated RE: print output none - buran - Nov-01-2021 cross-posted on StackOverflow RE: print output none - 3lnyn0 - Nov-01-2021 i found the problem |