Hi!
I have a task:
Write a function called has_duplicates that takes a list and returns True if there is any element that appears more than once. It should not modify the original list.
Here is my attempt but I dont know why I do fail!
Then has_dup(v) must be False but it gives me True every time ! why?
v[0] is not the same as v[1] or v[2], v[1] is not either the same like v[2], so why it increases the value of c ?
I have a task:
Write a function called has_duplicates that takes a list and returns True if there is any element that appears more than once. It should not modify the original list.
Here is my attempt but I dont know why I do fail!


def has_dup(v): c=0 for i in range(len(v)): for j in range(len(v)-1): if v[i]==v[j+1]: c=c+1 print(c) if c>1: return True if c<=1: return FalseIf v=['car','bar','are']
Then has_dup(v) must be False but it gives me True every time ! why?

v[0] is not the same as v[1] or v[2], v[1] is not either the same like v[2], so why it increases the value of c ?