Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python code begginer
#1
Hello I'm new in this page. I'm a beginner in python, and i have a question about this program.
I need to do this exercise:
Write a program to remove the duplicates in a list.
And i write this program:
n = [5, 3, 6, 7, 5, 5, 6, 7, 8, 3, 6, 5, 7, 8, 3, 4, 6, ]
for i in n:
    if n.count(i) > 1:
        n.remove(i)
print(n)
this is the answer: [5, 7, 3, 5, 7, 8, 3, 4, 6]
Can anyone tell my why this program doesn't work?
Sorry for my English, I'm learning. Thanks and regards
Reply


Messages In This Thread
python code begginer - by abdielG252 - Jun-22-2019, 07:23 PM
RE: python code begginer - by noisefloor - Jun-22-2019, 07:47 PM
RE: python code begginer - by perfringo - Jun-22-2019, 07:59 PM
RE: python code begginer - by ankit - Jun-24-2019, 07:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Coding begginer Verner 1 1,333 Jan-24-2022, 11:27 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020