Generation

generate functionMon, 26 Dec 2022

There are two lists. The first (stnums) contains rows that are considered duplicates. The second list is a list of students. Write a function that replaces the values in the second list that match the first (but only the 2nd, 3rd value, and so on, not the first one). stnums = ['4004'] students = [ ['0001', 'Antonov', 'Anton', 'Igorevich', '20.08.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 replace(stnums, students): for i in stnums: for j in students: if i == j[0]: students.remove(j) return students

Questions about programming?Chat with your personal AI assistant