Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

using enumerate() and zip() together

names = ['Alice', 'Bob', 'Charlie']
ages = [24, 50, 18]

for i, (name, age) in enumerate(zip(names, ages)):
    print(i, name, age)
# 0 Alice 24
# 1 Bob 50
# 2 Charlie 18
Comment

enumerate zip together

# create a list of names
names = ['Messi', 'Mane']
  
# create a list of subjects
subjects = ['hat-trick', ' hat-trick']
  
# create a list of marks
marks = [99, 98]
  
# use enumerate() and zip() function
# to iterate the lists with t function
for i, t in enumerate(zip(names, subjects, marks)):
    print(i, t)
 #Ouput:
0 ('Messi', 'hat-trick', 99)
1 ('Mane', 'hat-trick', 98)
Comment

PREVIOUS NEXT
Code Example
Python :: for i in range(6, 11): print(i, end="") 
Python :: ascii julius caesar python encryption 
Python :: joining datasets by id python 
Python :: view(-1 1) pytorch 
Python :: Add 1 to loops 
Python :: python swap two numbers 
Python :: python replace every space, dash and parentheses into underscore 
Python :: Algorithms and Data Structures in Python (INTERVIEW Q&A) 
Python :: python create empty list with size 
Python :: get parent keys of keys python 
Python :: transfer learning in python with custom dataset 
Python :: attach short list to pandas dataframe with filler 
Python :: Algorithm of Broadcasting with NumPy Arrays 
Python :: Python NumPy ravel function example Showing ordering manipulation 
Python :: conmbination in python 
Python :: Python NumPy asarray Function Example Tuple to an array 
Python :: Python NumPy vstack Function Example with 2d array 
Python :: verbose field names 
Python :: https://www.geeksforgeeks.org/matplotlib-axes-axes-cla-in-python/ 
Python :: __ne__ 
Python :: calculate mse loss python 
Python :: NumPy left_shift Code When inputs and bit shift are numbers 
Python :: http://172.18.0.128:8114/ 
Python :: complete dates pandas per group by 
Python :: celery 5.2.3 decorators 
Python :: Use one function for the "ComboboxSelected", to read multiple combobox 
Python :: python turtle star 
Python :: Fetch all links from a given webpage 
Python :: sklearn encoding pipelin 
Python :: cyclic rotation python 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =