Skip to content
Closed
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
16 changes: 16 additions & 0 deletions snippets/python/list-manipulation/zip-two-lists
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Zip two lists
description: Combines the corresponding elements of lists into a new list
author: TejaReddyAlla
tags: python,list,zip,utility
---

```py
def zip_lists(lst1, lst2):
return list(zip(lst1, lst2))

# Usage:
lst1 = [1, 2, 3]
lst2 = ['a', 'b', 'c']
print(zip_lists(lst1, lst2)) # Output: [(1, 'a'), (2, 'b'), (3, 'c')]
```