My list contains many duplicates values and I want to remove all duplicates and make it unique. For this purpose, I have developed a code but it is giving error to me. I’m not getting what error is trying to communicate. Here it is:
Error:
NameError Traceback (most recent call last)
Cell In[1], line 5
3 # Remove duplicates using a loop
4 for item in my_list:
----> 5 if item not in new_list:
6 new_list.append(item)
8 print(new_list)
NameError: name 'new_list' is not defined
Here is my code that I wrote:
Can someone correct my mistakes? If you know any other method, I would appreciate it for sharing it with me.