First solution in Clear category for Common Words by Sjama
def checkio(line1: str, line2: str) -> str:
#set(line.split(",")) creates a list of the words and converts it to a set
#being a set we can use the intersection method (x.intersection(y) returns a set containing only items that are present in both x & y)
#the resulting set is joined into a string with a "," in between as the exercise requires
if __name__ == '__main__':
# These "asserts" are used for self-checking and not for an auto-testing
assert checkio('hello,world', 'hello,earth') == 'hello'
assert checkio('one,two,three', 'four,five,six') == ''
'four,five,one,two,six,three') == 'one,three,two'
print("Coding complete? Click 'Check' to earn cool rewards!")
May 25, 2021