I have a dictionary
lang = {\'ar\':\'arabic\', \'ur\':\'urdu\',\'en\':\'english\'}
What I want to do is to delete all the keys except one key.
Iterate over keys() instead:
keys()
for k in lang.keys(): if k != 'en': del lang_name[k]
If you're using Python 3 I believe you need to use list(lang.keys()) instead.
list(lang.keys())