Skip to content

Instantly share code, notes, and snippets.

@websofter
Created July 23, 2021 13:44
Show Gist options
  • Select an option

  • Save websofter/b6b6ca518a83cdd7d90c803938ac66f0 to your computer and use it in GitHub Desktop.

Select an option

Save websofter/b6b6ca518a83cdd7d90c803938ac66f0 to your computer and use it in GitHub Desktop.
Convert Python dictionary array to dictionary property array
posts = [
{'name': 'Name 1', 'text': 'Some text 1'},
{'name': 'Name 2', 'text': 'Some text 2'},
{'name': 'Name 3', 'text': 'Some text 3'},
{'name': 'Name 4', 'text': 'Some text 4'}
]
posts_text = []
posts_text = list(map(lambda p: p['text'], posts))
print(list(posts_text))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment