This code is a function named “getPairs” which takes a list as an input and outputs the pairs of duplicated elements in the list.
def getPairs(myList):
for i in range(0, len(myList)):
for j in range(i + 1, len(myList)):
if (myList[i] == myList[j]):
print(
"Number " + str(myList[i]) +
" is included two times, at indices " +
str(i) + " and " + str(j))
myList = [1, 3, 4, 6, 1, 9, 4, 8, 9]
getPairs(myList)
Number 1 is included two times, at indices 0 and 4
Number 4 is included two times, at indices 2 and 6
Number 9 is included two times, at indices 5 and 8