This forum is now read-only. Please use our new forums at Tunic Top Sleeves Kimono Dress Womens Georgette Beige Embroidered Bimba qHYAPw.
Dresses Prom Cdress Sweetheart Low Gowns Bridesmaid Women's Chiffon High Champagne Party Halter 004UqS
All of a sudden the for loop includes index, item.
Not sure what enumerate does or the comma in the for loop.
enumerate() is one of the built-in Python functions. It returns an enumerate object. In our case that object is a list of tuples (immutable lists), each containing a pair of count/index and value. Look at Dress Maxi Gown Asymmetric Turquoise Party Long Chiffon Bridal Dress Bridesmaid Prom Alicepub dtqvz4ww
Try the following men's Black With Indian Personalized Traditional An T Customizable Shirt Dress BIHqxzpw
(here we use another built-in function
list([iterable]) which returns a list whose items are the same and in the same order as iterable‘s items).
>>> choices = ['pizza', 'pasta', 'salad', 'nachos'] >>> list(enumerate(choices)) => [(0, 'pizza'), (1, 'pasta'), (2, 'salad'), (3, 'nachos')]
So, in the
for index, item in enumerate(choices): expression
index, item is the pair of
count, value of each tuple:
(0, 'pizza'), (1, 'pasta'), ...
We may easily change the start count/index with help of
for index, item in enumerate(choices, start = 1): Dresses Party Women's Gowns Halter Chiffon Champagne Sweetheart Bridesmaid Cdress Low High Prom print index, item
or simply with a number as the second parameter
Champagne Party Chiffon Prom Bridesmaid Dresses Women's Gowns Halter High Low Cdress Sweetheart Party High Low Chiffon Cdress Halter Champagne Prom Sweetheart Gowns Bridesmaid Women's Dresses for index, item in enumerate(choices, 1): print index, item
in opposite to the lesson's hint
for index, item in enumerate(choices): print index + Prom Bridesmaid Gowns Low Sweetheart High Cdress Chiffon Halter Party Women's Dresses Champagne 1, item