Menu

gitpiper

keys_only python Code Snippet in 2023

dictionarylistbeginner

Last Updated: 4 February 2023

Creates a flat list of all the keys in a flat dictionary.

  • Use dict.keys() to return the keys in the given dictionary.
  • Return a list() of the previous result.
def keys_only(flat_dict): return list(flat_dict.keys())
ages = { 'Peter': 10, 'Isabel': 11, 'Anna': 9, } keys_only(ages) # ['Peter', 'Isabel', 'Anna']

python snippet similar to keys_only For You in February 2023

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2023 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️