Facebook
From Capacious Stork, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 93
  1. # function 3
  2. def num_occur(s, c):
  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 c if x == s])
  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(words, c), x] for x in words]
  14.     return scored_occur

Replies to Untitled rss

Title Name Language When
Re: Untitled Social Butterfly text 3 Years ago.