[python] WorkingPython
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- import json
- f = open('/home/heyhey/progs/JS/countries.json')
- data = json.load(f)
- keys=['cym','deu','fra','hrv','ita','jpn','nld','por','rus','spa']
- key = input('Enter the key:')
- def translate(key):
- if key not in keys:
- print('Key is not supported!')
- elif key is None:
- print('Parameter cannot be empty!')
- else:
- for i in range(len(data)):
- print(data[i]['translations'][key])
- translate(key)
- f.close()
Editor
You can edit this paste and save as new: