In: Computer Science
For this assignment, we will learn to use Python's built in set type. It's a great collection class that allows you to get intersections, unions, differences, etc between different sets of values or objects.
1. Create a function named common_letters(strings) that returns the intersection of letters among a list of strings. The parameter is a list of strings.
For example, you can find the common letter in the domains/words statistics, computer science, and biology. You might easily see it, but you need to write Python code to compute the answer. In order to pass the tests you must use the set api.


# Define a function common_letters() that accepts a
# list of strings. It returns the intersection of
# letters from a given list of strings.
def common_letters(strings):
# Create and initialize a variable 'res' to store
# first string from a list of strings passed.
res=strings[0]
# Use for loop to traverse through a list of
# strings.
for letters in strings:
# Store the set of common letters from previous
# and current string into res variable.
res=set(res).intersection(letters)
# Return the list of common letters from list of strings.
return res
# Define a list of strings.
strings=['statistics','computer science', 'biology']
# Call the common_letters() function.
intersection=common_letters(strings)
# Display the result returned by common_letters().
print(str(intersection))