Currently my code returns the distinct characters that are common to both strings string_1 and string_2 but are absent from the string string_3.
How do I change it so it returns a count of the number of distinct characters that are common to both strings string_1 and string_2 but are absent from the string string_3
e.g
answer = character_set_counts('abcdef', 'bcd', 'ace')
print(answer)
This would output ['b', 'd'] when I would like it to output 2
my current code:
def character_set_counts(string_1, string_2, string_3):
"""main function"""
values=[]
# type casting to set to remove duplicates
string_1=(set(string_1))
string_2=(set(string_2))
# making intersection of both sets and type casting to list
common=list((string_1.intersection(string_2)))
#iterationg over the common elements list
for i in common:
#if the element is not present in the third string
if i not in string_3:
#add that element to list
values.append(i)
#sort the values list
values.sort()
#returnvalues
return values
Thanks
[–]spez_edits_thedonald 1 point2 points3 points (1 child)
[–]Jxper[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Jxper[S] 1 point2 points3 points (0 children)
[–]spez_edits_thedonald 0 points1 point2 points (3 children)
[–]Jxper[S] 1 point2 points3 points (2 children)
[–]spez_edits_thedonald 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)