Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions public/data/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@
"tags": ["python", "list", "flatten", "utility"],
"author": "technoph1le"
},
{
"title": "Flatten Unevenly Nested Lists",
"description": "Converts unevenly nested lists of any depth into a single flat list.",
"code": [
"def flatten(nested_list):",
" \"\"\"",
" Flattens unevenly nested lists of any depth into a single flat list.",
" \"\"\"",
" for item in nested_list:",
" if isinstance(item, list):",
" yield from flatten(item)",
" else:",
" yield item",
"",
"# Usage:",
"nested_list = [1, [2, [3, 4]], 5]",
"flattened = list(flatten(nested_list))",
"print(flattened) # Output: [1, 2, 3, 4, 5]"
],
"tags": ["python", "list", "flattening", "nested-lists", "depth", "utilities"],
"author": "agilarasu"
},
{
"title": "Remove Duplicates",
"description": "Removes duplicate elements from a list while maintaining order.",
Expand Down