sort()
Hello all!
Since i am started learn oython there is tons of questions in my mind:) Here is a simple for loop code ;
list = [4, 5, 7, 8, 9, 1, 0, 7, 10, 5] list.sort() prev = None for item in list: if prev == item: print("Duplicate of", prev,"found") prev = item
Questions are : #Why there is list.sort() under list? What if i dont want sort it? By the way if you remove this code program doest show results.
and why in end of the code there is "prev = item" ?
Thank you a lot!