filmov
tv
Two lists can be iterated Simultaneously using zip keyword in Python #shorts
Показать описание
Python zip() function is defined as zip(*iterables). The function takes in iterables as arguments and returns an iterator. This iterator generates a series of tuples containing elements from each iterable. zip() can accept any type of iterable, such as files, lists, tuples, dictionaries, sets, and so on.
example:
letters = ['a', 'b', 'c']
numbers = [0, 1, 2]
operators = ['*', '/', '+']
for l, n, o in zip(letters, numbers, operators):
print(f'Letter: {l}')
print(f'Number: {n}')
print(f'Operator: {o}')
#Shorts #youtubeshorts #python #zip #iterator #for
example:
letters = ['a', 'b', 'c']
numbers = [0, 1, 2]
operators = ['*', '/', '+']
for l, n, o in zip(letters, numbers, operators):
print(f'Letter: {l}')
print(f'Number: {n}')
print(f'Operator: {o}')
#Shorts #youtubeshorts #python #zip #iterator #for