while aware best , simplest method find duplicates in list using collections.counter, wish know following logic fail.
def uniquenumbercheck(listarg): in range(2,len(listarg)): j in range(1,i-1): if(listarg[i]==listarg[j]): print("duplicate value appeared : "+str(listarg[i])) return print("all entered values unique. ") the program running failed display correct output.could not figure out mistake.for example input of 1,1,0 integers list, says unique.
off-by-one error. in python, indexes start @ 0, not 1. so,
for in range(2, len(listarg)): j in range(1, - 1): should be:
for in range(1, len(listarg)): j in range(0, i): also, range(1, len(listarg)) can written range(len(listarg)).
Comments
Post a Comment