from copy import copy, deepcopy a = [[1, 2, 3], [23, 8, 7], [], [2, 1]] #b = a #b = copy(a) b = deepcopy(a) b[0] = [2, 9] b[1][1] += 3 print(b) print("*----------------------*") print(a) strlist = ["ahoj", "svete", "zkousim", "porovnani"] listlist = [[1, 2, 3], [23, 8, 7], [2, 1]] #tim jsme zkouseli ze sum() na seznam retezcu hodi chybu #print(sum(strlist)) #print(sum(listlist)) print("*----------------------*") print(min(strlist)) print(min(listlist)) def dummy(text, rubbish): result = "" for c in text: result += c + rubbish return result[:len(result)-len(rubbish)] def reverse(text): result = "" for i in range(len(text) -1, -1, -1): result += text[i] + " " return result def rev_simple(text): return text[::-1] print(dummy('pampeliska', 'XX')) # 'pXXaXXmXXpXXeXXlXXiXXsXXkXXa' print(reverse('ONMEJATEJOLSEH')) print(rev_simple('ONMEJATEJOLSEH')) # H E S L O J E T A J E M N O def vigenere(text, klic): result = "" i = 0 for c in text: """ # tento blok odpovida tomu dlouhemu vyrazu plainCharPos = ord(c) - ord('a') keyCharIndex = i%len(klic) keyCharPos = ord(klic[keyCharIndex]) - ord('a') posSum = plainCharPos + keyCharPos resultCharPos = posSum % 26 resultCharOrd = resultCharPos + ord('a') result += chr(resultCharOrd) """ result += chr(((ord(c) - ord('a') + ord(klic[i%len(klic)]) - ord('a')) % 26) + ord('a')) i += 1 return result print(vigenere('pampeliska', 'klic')) # ZLUROWQUUL