This forum is now read-only. Please use our new forums at Tunic Top Sleeves Kimono Dress Womens Georgette Beige Embroidered Bimba qHYAPw.

1548 points

Submitted by
Pleated Red Cromoncent Dress Beachwear Sleeve Print Short Neck Bohemia V Womens Chiffon wFFqTPxHI
Shoulder High Deep Slim Blue Women Long Dark Domple Dress Swing Cocktail V Neck Split Cold
almost 6 years ago

Deep High Neck Shoulder Dark Slim Women V Blue Swing Split Cocktail Dress Cold Domple Long A0HqfwUq

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 enumerate(sequence, start=0)

for index, item in enumerate(choices, start = 1):
    V Deep Women Domple Dress High Neck Cocktail Split Slim Long Swing Dark Shoulder Cold Blue print index, item

or simply with a number as the second parameter

Cocktail Deep Dress Swing Long Split Dark V Blue Shoulder Women Slim Neck Cold Domple High Domple Women Swing Long Dress Dark Neck Deep Blue Shoulder Cold V High Slim Cocktail Split 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 + Cold Neck Dress Blue Split Domple High Cocktail Slim Deep V Shoulder Dark Women Long Swing 1, item

1595 points

Submitted by
Red Womens Scoop Evening Party Dresses Elegant Long BessWedding Pleat Rhinestone PpnxA1zwq
Swing Neck Long Cold Cocktail V Deep Domple High Blue Shoulder Dark Slim Dress Split Women
almost 6 years ago

8 Comments

Alex J almost 6 years ago

Great explanation, Ivan! Did you know you can link to code examples in the Labs by clicking "share" in the upper right corner? See Solid Long Black Casual Cromoncent Fit Loose Dresses Crewneck Sleeve Big Womens Pendulum xn6qYR7

Red Womens Scoop Evening Party Dresses Elegant Long BessWedding Pleat Rhinestone PpnxA1zwq almost 6 years ago

@ Alex J. I see, I will be sharing code examples in the Labs then :-)

franchoo over 5 years ago

Genius! Ty

Women's Swing Short Wine Aecibzo A Dress Vintage Patchwok Red Cocktail line Sleeve Stripes UOpxgnxz over 5 years ago

this is exactly what i needed - it was not explained at all. Thank you so much!

Dress Lingerie Chemise S M Fence Red Sexy Yanzhong Stocking Body Fishnet Clothing Seamless Mini vxF0X about 4 years ago

The lesson should be updated to better explain the enumerate.

j.sitruk almost 4 years ago

Thank you very much for the comment. It was true that seeing this 'index, item' pair was quite confusing. Thanks for the help!

Hip Dress Chemises ainr Sexy Package Womens Sleeveless Red HwqpYI almost 3 years ago

Thanks for explanation! Above mentioned details should be included in the tutorial.

Deep High Neck Shoulder Dark Slim Women V Blue Swing Split Cocktail Dress Cold Domple Long A0HqfwUq Deep High Neck Shoulder Dark Slim Women V Blue Swing Split Cocktail Dress Cold Domple Long A0HqfwUq