0
0 комментариев
def checkio(a):
    #Your code here
    #replace this for solution
    result=[]
    for i in range(len(a)):
        for j in range(len(a)):
            if a[i]==a[j] and i!=j:#если такие элементы есть
                result.append(a[i])#копируем в result
    return result
 
if __name__ == "__main__":
    #These "asserts" using only for self-checking and not necessary for auto-testing
    #assert
    assert list(checkio([1, 2, 3, 1, 3]))==[1,3,1,3]
    assert list(checkio([1, 2, 3, 4, 5])) == [], "2nd example"
    assert list(checkio([5, 5, 5, 5, 5]))== [5, 5, 5, 5, 5],checkio([5, 5, 5, 5, 5])
    assert list(checkio([10, 9, 10, 10, 9, 8])) == [10, 9, 10, 10, 9], checkio([10, 9, 10, 10, 9])

Но выходит такой assert:

assert list(checkio([5, 5, 5, 5, 5]))== [5, 5, 5, 5, 5],checkio([5, 5, 5, 5, 5])
AssertionError: [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]


Добавить комментарий