Answers for "Given a list of strings, find the list of characters that appear in all strings."

0

Given a list of strings, find the list of characters that appear in all strings.

# Common characters in n strings:

def findAllC(list):
  # Take every single characters in the strings in the list
    chrs = set("".join(list))
    out = []
    for i in chrs:
      # for each chrs in list count the chrs, if count is 0 break and repeat
        for j in range(0, len(list)):
            if list[j].count(i) == 0:
                break
			# at the end if is not break append the chrs in list
            if j == len(list) - 1:
                out.append(i)
    return out


print(findAllC(['google', 'facebook', 'youtube']))
# ['o', 'e']
Posted by: Guest on January-17-2021

Code answers related to "Given a list of strings, find the list of characters that appear in all strings."

Python Answers by Framework

Browse Popular Code Answers by Language