fork(2) download
  1. from collections import Counter
  2.  
  3. def find_needle(n,h):
  4. c = Counter()
  5. c.update(h.split())
  6. return c[n]
  7.  
  8. n = "portugal"
  9. h = 'lobito programmer from portugal hello fromportugal portugal'''
  10.  
  11. print find_needle(n,h)
Success #stdin #stdout 0.01s 7844KB
stdin
Standard input is empty
stdout
2