1. first_last: (2 points) This function takes a list and returns a 2-tuple (a tuple with two values) containing the first and last elements of the list. Assume the list is not empty. Strive for a one-liner, just return SOMETHING.
2. dups_dict: (7 points) This one takes as its only argument a dictionary that maps keys to
lists of values. Return True if any of the values in the lists occur more than once
anywhere in the lists; False otherwise.
3. substr_in_values: (10 points) This function takes a dictionary that maps keys to lists of
strings and a string. Return a sorted list of all keys that have an associated value
containing a string that case-insensitively contains the second argument.
4. count_lets: (18 points) This function's only required argument is a string. It returns a list
with both (1) all letters that appear in the string and (2) a count of the number of
times that each appears. Here's an example:
We might expect that the count/letter pairs would be tuples, but they simply
aren't!Instead, the values in the list alternate between a count and the letter that had that
count. Notice that only lowercase letters appear in the result; uppercase letters are
translated to lowercase and non-letters (not a-z or A-Z) are discarded.
A second, optional parameter named all indicates that counts for all twenty-six letters
should be produced, regardless of whether they appeared. Example:
Get Free Quote!
260 Experts Online