Answer the question
In order to leave comments, you need to log in
I can not understand the cycle of the program?
spisok = [1, 2, 3, 2, 3]
print(spisok)
spisok.sort()
n = len(spisok)
i=0
for l in range(n-1):
for j in range(n-l-1):
if spisok[j]==spisok[j+1]:
i+=1
print(i)
Answer the question
In order to leave comments, you need to log in
If I understand the purpose correctly, then something like this should be:
for l in range(n-1):
for j in range(l+1, n):
if spisok[l]==spisok[j]:
i+=1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question