Facebook
From Social Butterfly, 3 Years ago, written in Plain Text.
This paste is a reply to Untitled from Capacious Stork - view diff
Embed
Download Paste or View Raw
Hits: 128
  1. # function 3
  2. def num_occur(c, s):
  3.     """takes a single character c and an arbitrary string s
  4.     and returns the number of times that c occurs in s"""
  5.     lc = ([x for x in s if x == c])
  6.     return len(lc)
  7.  
  8. # function 4
  9. def most_occur(c, words):
  10.     """ takes a single character c and a list of one or
  11.     more strings called words and returns the string in
  12.     the list with the most occurrences of c"""
  13.     scored_occur = [[num_occur(c, words), x] for x in words]
  14.     return scored_occur