homeworkhelp111

Dictionary word count

Oct 17th, 2021 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. def main():
  2.     Dict = {}
  3.     line = input().split()
  4.     for x in line:
  5.         if x in Dict:
  6.             Dict[x] = Dict[x]+1
  7.             print(str(Dict[x]), end=" ")
  8.         else:
  9.             Dict[x] = 0
  10.             print(str(0), end =" ")
  11.  
  12. if __name__ == '__main__':
  13.     main()
  14.        
Add Comment
Please, Sign In to add comment