mod u4
This commit is contained in:
parent
27305dd122
commit
85f4c96268
@ -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] = " "
|
||||
|
||||
Loading…
Reference in New Issue
Block a user