Nov-07-2019, 10:29 PM
Hi, I want to print the occurence of each item . For example, you want 5 items in (1,1). Instead of printing 1,1,1,1,1 ; I want it to print 1:"5". I'm struggling with it for hours. Please could you check what s wrong in my function? Thanks!
def fonction3(n,a,b):
import random
L=[]
L2=[]
for k in range(n):
r= random.randint(a,b)
x= str(r)
L.append(x)
for item in L:
count=L2.count(n)
print(item + ":" + "\""+str(count)+"\"" )
print("There are",(len(L)), "items")
return L
