Python OOPs


Python SQLite


Examples


Others


Python - zip()


The zip() method takes one or more iterables and used to merge the iterables. zip() method returns a zip object(returns an iterator of tuples with each tuple having elements from all the iterables). We could convert a zip object into a list by list(zip_obj).

Syntax
zip(iterator1,iterator2 ,...,iteratorN)

Write a Python program to merge 2 list into one with same index using zip.

Example
name=["Sara","Sam","Tom","Ram"]
mark=[98,86,74,85,93]

x=zip(name,mark)
print(list(x))
Output
[('Sara', 98), ('Sam', 86), ('Tom', 74), ('Ram', 85)]