Menu

gitpiper

keys_only python Code Snippet in 2024

dictionarylistbeginner

Last Updated: 13 April 2024

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 April 2024

Subscribe to our Newsletter

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

© 2024 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! ✌️