I'm trying to find if there is a duplicate within a list without using the in-built functions. So far I have something like this however it does not seem to be working. Can anyone help? Give pointers? Improvements? I'd appreciate it. (Python version 2.7.10)
def DupSearch(list):
counter=0
for i in range(len(list)):
if list[i]==list[0]:
for j in range(len(list)):
if list[j]!=list[j+i]:
print "No duplicated"
else:
counter=counter+1
if counter == len(list):
print "Duplicate found"
DupSearch([1,2,3,4,5,3])
len()andrange()are built-in functions. Can we useset()?set()?. Otherwise it'd simply beif len(list)!=len(set(list)): print True. else: print False?