Generation

generate functionMon, 26 Dec 2022

There are 2 functions. One looks for duplicate values and makes a dictionary. The second changes the duplicates to the desired value. The first function (find_duplicates) works correctly. But the second function (change_duplicates) is incomplete. Finish the code so that the duplicate student number changes to the one in brackets in the change_duplicates function. def find_duplicates(lst): stnums = [] cnt = {} for el in lst: stnums.append(el[0]) for i in stnums: if i in cnt: cnt[i] += 1 else: cnt[i] = 1 return cnt def change_duplicates(lst, replacing_num): stnums = [] duplicates = find_duplicates(lst) for k, v in duplicates.items(): if v > 1: stnums = [k] for student in lst: if stnums in lst: #need right code#

# Python ## Python Basics ### Basic Syntax Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms. The official Python website is www.python.org. There you will find the latest Python documentation. There are also mailing lists, newsgroups, and a number of other resources available at the site. ### Running Python The Python interpreter is usually installed as /usr/local/bin/python3.7 on those machines where it is available; putting /usr/local/bin in your Unix shell’s search path makes it possible to start it by typing the command:

Questions about programming?Chat with your personal AI assistant