Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Common Words by jtarnowska
def checkio(first, second):
split1 = first.split(",")
first_list = []
for word in split1:
first_list.append(word)
split2 = second.split(",")
second_list = []
for word in split2:
second_list.append(word)
text_list = []
for i in range (len(first_list)):
if first_list[i] in second_list:
text_list.append(first_list[i])
print(text_list)
text = ""
text = ",".join(text_list)
text_split = text.split(",")
split_list = []
for i in range (len(text_split)):
split_list.append(text_split[i])
print(type(split_list))
split_list.sort()
print(type(split_list))
sorted_text = ""
sorted_text = ",".join(split_list)
print(sorted_text)
return(sorted_text)
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("hello,world", "hello,earth") == "hello", "Hello"
assert checkio("one,two,three", "four,five,six") == "", "Too different"
assert checkio("one,two,three", "four,five,one,two,six,three") == "one,three,two", "1 2 3"
Jan. 11, 2017