(Solved):Write the following function (with comments but no screenshot of the execution) def letters(str1) that takes a string argument str1 and returns a set of only letters (“a-z” and “A-Z”) that are cont… View Answer…

 

Question

Write the following function (with comments but no screenshot of the execution)

def letters(str1)

that takes a string argument str1 and returns a set of only letters (“a-z” and “A-Z”) that are contained in the string.

 

EXPERT ANSWER

The function can be implemented as follows:

The string is converted into C type string. The C type string is then traversed one character at a time to see if the character is one of

Scroll to top