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

Example: 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']

Tags:

Misc Example