Generation

generate functionMon, 26 Dec 2022

Write a code that looks for a repeating student number and replaces it with "9090". lst = [ ["0001", "Antonov", "Anton", "Igorevich", "08/20/2009", "BST161"] ["1102", "Bogov", "Artem", "Igorevich", "25.01.2010", "BST162"] ["0333", "Glagoleva", "Anastasiya", "Nikolaevna", "11.07.2009", "BST163"] ["4004", "Stepanova", "Natalia", "Aleksandrovna", "13.02.2008", "BST161"] ["0045", "Bokov", "Igor", "Kharitonovich", "02.06.2009", "BST161"], ["0096", "Vasil'kov", "Valentin", "Sergeevich", "20.03.2009", "BST164"], ["0607", "Siropova", "Violetta", "Eduardovna", "28.05.2010", "BST162"], ["4004", "Potapov", "Dmitry", "Stanislavovich", "14.02.2012", "BST161"] ]

def find_duplicates(lst): new_lst = [] for i in lst: if i[0] not in new_lst: new_lst.append(i[0]) else: i[0] = "9090" return new_lst find_duplicates(lst)

Questions about programming?Chat with your personal AI assistant