From 85f4c96268bb3242b964cf0fb993ffdd060d09e1 Mon Sep 17 00:00:00 2001 From: MartinSkovran Date: Tue, 27 Oct 2026 15:03:30 +0100 Subject: [PATCH] mod u4 --- u4/word_count.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/u4/word_count.py b/u4/word_count.py index 89e8316..3928b10 100644 --- a/u4/word_count.py +++ b/u4/word_count.py @@ -1,14 +1,12 @@ from collections import defaultdict -def isalnum_without_apostroph(ch: str): - return ch.isalnum() and ch != "'" def count_words(sentance: str) -> dict: sent_list = list(sentance) words = defaultdict(int) for i, ch in enumerate(sent_list): if(ch == "'"): - if((isalnum_without_apostroph(sent_list[max(i-1, 0)])) and (isalnum_without_apostroph(sent_list[min(i+1, len(sent_list)-1)]))): + if((sent_list[max(i-1, 0)].isalnum()) and (sent_list[min(i+1, len(sent_list)-1)].isalnum())): pass else: sent_list[i] = " "