Skip to content

Commit 901056c

Browse files
zip-two-lists in python
1 parent f1f3b6a commit 901056c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Zip two lists
3+
description: Combines the corresponding elements of lists into a new list
4+
author: TejaReddyAlla
5+
tags: python,list,zip,utility
6+
---
7+
8+
```py
9+
def zip_lists(lst1, lst2):
10+
return list(zip(lst1, lst2))
11+
12+
# Usage:
13+
lst1 = [1, 2, 3]
14+
lst2 = ['a', 'b', 'c']
15+
print(zip_lists(lst1, lst2)) # Output: [(1, 'a'), (2, 'b'), (3, 'c')]
16+
```

0 commit comments

Comments
 (0)