Advertisement
prabhavms

Q5(cyclesheet 6)

Dec 27th, 2021
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. def frequency(str):
  2.     str = str.split()        
  3.     str2 = []
  4.     for i in str:            
  5.         if i not in str2:
  6.             str2.append(i)
  7.              
  8.     for i in range(0, len(str2)):
  9.         c = str2.sort()
  10.         d = str.count(str2[i])
  11.         if d > 0 :
  12.             print(str2[i],'-',d)
  13.  
  14. str = input()
  15. frequency(str)                    
  16.  
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement