From 665b8f3835a22fd30d6238bfe3fdf44e86e9267f Mon Sep 17 00:00:00 2001 From: Lukas Baumann Date: Mon, 22 Feb 2021 11:34:20 +0100 Subject: [PATCH] Update 3 - Poetic Analysis.py --- 15/b/3 - Poetic Analysis.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/15/b/3 - Poetic Analysis.py b/15/b/3 - Poetic Analysis.py index b8d6eaa..533abd3 100644 --- a/15/b/3 - Poetic Analysis.py +++ b/15/b/3 - Poetic Analysis.py @@ -1,14 +1,7 @@ -txt = input().split() +txt = input().lower().split() while txt[-1] != "###": - txt += input().split() -amount = {} -for i in txt: - if i.lower() in amount: - amount[i.lower()] += 1 - else: - amount[i.lower()] = 1 -max = ["", 0] -for i in amount: - if amount[i] > max[1]: - max = [i, amount[i]] -print(max[0]) + txt += input().lower().split() +m = [0]*len(txt) +for i in range(len(txt)): + m[i]=txt.count(txt[i]) +print(txt[m.index(max(m))])