From b1299c5c494f5c3f3068ea99a31b0f5db411ab38 Mon Sep 17 00:00:00 2001 From: s45163 Date: Sat, 2 Dec 2017 09:30:37 +0100 Subject: [PATCH] python_01 --- labs02/task11.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/labs02/task11.py b/labs02/task11.py index de296d4..1705b5f 100644 --- a/labs02/task11.py +++ b/labs02/task11.py @@ -9,11 +9,26 @@ Oba napisy będą składać się wyłacznie z małych liter. """ def common_chars(string1, string2): - slowo = sort(sum(c1 == c2 for c1, c2 in zip(string1, string2))) -print (slowo) + + string1 = set(string1.replace(" ","")) + string2 = set(string2.replace(" ","")) + + common = [] + for c1 in string1: + for c2 in string2: + if c1 == c2: + common.append(c1) + common.sort() + return common + + + # slowo = sum( c1 == c2 for c1, c2 in zip(string1, string2)) + # print(slowo) + # return slowo + def tests(f): inputs = [["this is a string", "ala ma kota"]] outputs = [['a', 't']]