This is the final chapter of the lists in python topic, in this chapter we will create an example that will remove the duplicate student names within a student list with the help of the python loop.
We are given a list of student names, our mission is to remove the duplicate student name from the list.
student = ["Rick", "Ricky", "Richard", "Rick", "Rickky", "Rick", "Rickky"] # there are names that have been duplicated double_enter =  # first we need to know all the duplicate student names for i in range(len(student)): count = student.count(student[i]) if count > 1: if student[i] not in double_enter: double_enter.append(student[i]) # then we will remove those duplicate student names for name in student: if name in double_enter and student.count(name) > 1: student.remove(name) print(student)
The above python program is very long, can you find a shorter method to achieve the above outcome? Write your own solution in the comment box below.