I am reading from a file and creating two lists, then sorting them after sorting I am trying to compare each elements number of occurances in a list but printing them with that number for example if a list is something like {1,2,3,3,3,5,5,5,6} then I want to print a report like 1 count =1 2 count =1 3 count = 3 5 count = 5 6 count =6.
this is what I have so far just one small thing I need to get it done.
def main():
data = open("Iris.csv",'rU')
petalWidths = []
sepalWidths = []
for line in data:
line = line.split(',')
sepalWidths.append(line[1])
petalWidths.append(line[3])
sepalWidths.sort()
checkForWidthCount(sepalWidths)
petalWidths.sort()
print sepalWidths
## print petalWidths
def checkForWidthCount(mylist):
for x in range(0,len(mylist)-1):
count = 0
for y in range (0,len(mylist)-1):
if mylist[x] == mylist[y]:
count+=1
else:
y+=count
#x+=count
print mylist[x],count
main()