25 May PMCA Saturday 18:30 Python Homework 21.05.22.
Posted at 03:32h in Uncategorized 0 Comments
Iven an list of words of strings made only from lowercase letters, return a list of all characters that are common in all the strings. Also, if the same character appears multiple times, then include that character only once.
convert all the words in the list into a set and use either set.intersection or set.intersection_update to find all the common items.
Sample Execution 1: Input ["bella", "label", "roller"] Output ['e', 'l'] Explanation In all the three strings in the list, only the characters e and l appear once Sample Execution 2: Input ['apple', 'orange', 'pineapple'] Output ['e'] Explanation Only character e is common in all the words of the string
Sorry, the comment form is closed at this time.