for i in seq:
for k in new:
if i not in new:
Please re-edit your Post
- leave one blank-line above of your code
- select your code in the Post
- then =click= on the </>-symbol-of-this-editor
Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.
@coderockstar00502 try to follow the editing guide that @leonhard_wettengmx_n has posted regarding code formatting. it makes it easier for people to help with the problem. This also allows for a quick response
But anyways here is your code corrected
def remove_duplicates(seq): new=[''] for i in seq: for k in new: if i not in new: new.append(i) new.remove('') return new m=[1,2,3,1,2,4,2,3,0,0,4,4,4,4,4] print (remove_duplicates(m))
Here was my original attempt
def remove_duplicates (items): newList =  value =  for i in items: if i in value: continue value.append(i) for i in value: newList.append(i) return(newList)
It works but it seems needlessly long for the task....
really liked your short code but you could write it like this
with less lines
def remove_duplicates(seq): newList =  for i in seq: if not in newList: newList.append(i) return(newList)
in his code did nothing for the solution. all he did was create a list with an empty string.
Which is why he ended up using this line
to take away that empty string in the list. But it was unnecessary.You got the answer right
Ah I completely misread that !!!!! Thanks any-ways
def remove_duplicates(listings): newList =  for i in range(len(listings)): if listings[i] not in newList: newList.append(listings[i]) return newList
I'm fairly new to programming in general so I'm often wondering whether there are coding best practices that I'm missing out on as I go forward as most of my scripts are shorter and less complex than what I see others post in these forums. For example, on this remove_duplicates function, I wound up using:
def remove_duplicates(items): new_lst =  for n in items: if n not in new_lst: new_lst.append(n) return new_lst
Which to me is simple, concise, and easily readable. Other functions I've been writing throughout these practices have been done in a similar manner. However, when I often look on here to see what others are doing, the code is more complicated than mine. So I'm left wondering if I'm getting into bad habits early on and perhaps I should be taking a different approach to how I logically build these functions.
I realize my comment is more general than this specific exercise, but this happens to be the one I was working on when I compared our codes.
Thanks, Leonhard. I had read your post and did what you said to do but I thought I was also remembering something about using three `s in front of each line or some such. Doing both obviously didn't work, but taking out the symbols and only using your instructions did the trick.