[Tutor] List issues

Wheeler, Gabriel wheelerg at seattleu.edu
Thu Apr 17 03:10:20 CEST 2014


Im having trouble completing this function with lists. Im supposed to create a function that will let me know if there are repeating elements so I wrote this and am not sure where the error lies. It is supposed to count the number of times a number appears and if its greater than 1 then it will say True.

#Problem 3

list = [1,2,2,2,3,4]

def duplicate(list):

    for i in range(len[list]):

        if list.count(i) > 1:

            return True

print duplicate(list)

Gabe Wheeler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140417/2e1caa3c/attachment.html>

More information about the Tutor mailing list