From 442fd6891fdc4afc6a324366383bda9e601dfda7 Mon Sep 17 00:00:00 2001 From: s45150 Date: Sun, 26 Nov 2017 15:05:03 +0100 Subject: [PATCH] commited tasks --- labs02/task10.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/labs02/task10.py b/labs02/task10.py index f380f0a..521ad8e 100644 --- a/labs02/task10.py +++ b/labs02/task10.py @@ -9,11 +9,29 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'. def pokemon_speak(text): - pass + #spacja Asci 32 + text_tmp = str(text) + text_tmp = text_tmp.replace('[', '') + text_tmp = text_tmp.replace(']', '') + text_tmp = text_tmp.replace("'", '') + lista_temp = "" + j = 1 + for i in text: + if ord(i) == 32: + j=1 + lista_temp += i + else: + if j%2 == 0: + lista_temp += i + else: + lista_temp += i.upper() + j += 1 + return lista_temp + def tests(f): - inputs = [['pokemon'], ['do not want'], 'POKEMON'] + inputs = [['pokemon'], ['do not want'], ['POKEMON']] outputs = ['PoKeMoN', 'Do nOt wAnT', 'POKEMON'] for input, output in zip(inputs, outputs):