aboutsummaryrefslogtreecommitdiff
path: root/challenge-255/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-255/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-255/eric-cheung/python/ch-2.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-255/eric-cheung/python/ch-2.py b/challenge-255/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..046fceb06e
--- /dev/null
+++ b/challenge-255/eric-cheung/python/ch-2.py
@@ -0,0 +1,19 @@
+
+import numpy as np
+
+## Example 1
+## strPara = "Joe hit a ball, the hit ball flew far after it was hit."
+## strBan = "hit"
+
+## Example 2
+strPara = "Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge."
+strBan = "the"
+
+arrWordSet = strPara.replace(strBan, "").replace(",", "").replace(".", "").split()
+arrWordUniqSet = list(set(arrWordSet))
+arrWordCount = [arrWordSet.count(wordLoop) for wordLoop in arrWordUniqSet]
+
+## print (arrWordUniqSet)
+## print (arrWordCount)
+
+print (arrWordUniqSet[np.argmax(arrWordCount)])