Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t=[5,2,1,5,2,2,1,2,1]
- t.sort()
- def najczczestszy(A):
- aktualny=A[0]
- ile=1
- najczesy=A[0]
- ile_najcz=1
- for i in range(1,len(A)-1):
- if A[i]==A[i-1]:
- ile+=1
- if ile>ile_najcz:
- ile_najcz=ile
- najczesy=aktualny
- else:
- aktualny=A[i]
- ile=1
- return str(najczesy)+" występuje "+str(ile_najcz)
- print(najczczestszy(t))
Advertisement
Add Comment
Please, Sign In to add comment