Not sure after quick skim/scan, but, I would generally use either for I in range(len(inlist)): or just for it in inlist, instead of using while, etc.
Stay well Jacob Kruger Blind Biker Skype: BlindZA "Roger Wilco wants to welcome you...to the space janitor's closet..." ----- Original Message ----- From: Thuruv V To: python-list@python.org Sent: Wednesday, December 31, 2014 11:25 PM Subject: Why For Loop Skips the Last element? Hi all, Here's the list. . inlist = ["Fossil Women's Natalie Stainless Steel Watch Brown (JR1385)", 'Balmer Swiss Made Veyron Mens Watch: Black Band/ Black Dial (62625241)', 'Fortune NYC Ladies Quilted Dial Watch: Brown', 'Jeanne Collection w/ Swarovski Elements Watch: Dark Purple Band (62623659)', 'Swiss Legend Commander Chronograph: Watch Orange/Black (SL-10067-01-ORS)', 'Debussy Ladies Watch: Brown/Gray/Silver 14070 - 62625292', '#2 Swiss Legend Commander Chronograph: Green (SL-10067-BB-017)', 'Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial (62625184)' ] My code : i = 0 while i <= len(inlist): if 'watch' in str(inlist[i]).lower() or 'watches' in str(inlist[i]).lower(): if 'women' in str(inlist[i]).lower() or 'female' in str(inlist[i]).lower() or 'ladies' in str(inlist[i]).lower(): print 'FEMale Watch', inlist.index(i),str(i) elif 'men' in str(inlist[i]).lower() or 'male' in str(inlist[i]).lower() or 'chronograph' in str(inlist[i]).lower(): print 'Male Watch',inlist.index(i),str(i) i = next(inlist) When on executing python skips the last element('Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial (62625184)') in the list. But when accessing through 'print inlist[0]' is possible,i.e it shows the e;lement. but the list skips it. . Please enlighten me. . Thanks. ------------------------------------------------------------------------------ -- https://mail.python.org/mailman/listinfo/python-list
-- https://mail.python.org/mailman/listinfo/python-list