codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with rearanging list with paired letters next to each others


Can anybody help?Here's the code that gives me a hedeache for second day https://bpa.st/XLOA 
If I have letter_list = ["a","a",,"b","b","c","c"] it's working
correctly but if I have three or more of any letters for
example:letter_list = ["a","a","a","b","b","c","c"], I'm ending up with
some pairs somewhere.
I took another way approach today: https://bpa.st/E7HQ, was thinking
about iterating and checking if neighbour characters won't make a pair
but I've end up with error:
if x != letter_list[i+1] and letter_list[i-1]:
IndexError: list index out of range
andin addition: got 4 "a" (had 3only) and missing 1 "b" :-/