[Tutor] Help with duplicates using for...

Guess Who? Me beercanz@hotmail.com
Sun, 30 Jun 2002 03:14:07 +0000


<html><div style='background-color:'><DIV>list = [4, 5, 7, 8, 9, 1,0,7,10]<BR>list.sort()<BR>prev = list[0]<BR>del list[0]<BR>for item in list:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if prev == item:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Duplicate of ",prev," Found"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prev = item<BR></DIV>
<DIV>I don't understand this piece of code. I don't get why you have to remove the first list value. Could somebody please explain it some ? I almost have it.</DIV>
<DIV>Thanks,</DIV>
<DIV>Travis</DIV></div><br clear=all><hr>Send and receive Hotmail on your mobile device: <a href='http://g.msn.com/1HM1ENUS/c152??PI=44364'>Click Here</a><br></html>