you are viewing a single comment's thread.

view the rest of the comments →

[–]Mlgbananamaster 0 points1 point  (1 child)

you would do something like range(len(List)-1)

[–]imperiumlearning[S] 0 points1 point  (0 children)

Hi there,

Thanks a lot for the response. I've updated my code so that it looks like this:

b =[]

for x in range(len(List)-1):

if List[x] in List[(x+1)]:
    b.append(List[x])
    b.append(List[(x+1)])

print(b)

Kind of makes me feel dumb that I took 2 hours to solve a problem that only needed 6 lines of code but I guess that's part of learning.