Add Lab1, Problem1 and Problem2
This commit is contained in:
parent
973661fcbf
commit
5978779a9a
3 changed files with 61 additions and 0 deletions
12
thinkcspy/Chapter-12-Exercises/Lab1.py
Normal file
12
thinkcspy/Chapter-12-Exercises/Lab1.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def countAll(text):
|
||||
wordDict = {}
|
||||
|
||||
for char in text:
|
||||
if char not in wordDict and char.isalpha():
|
||||
wordDict[char] = text.count(char)
|
||||
|
||||
return wordDict
|
||||
|
||||
|
||||
print(countAll("banana"))
|
||||
print(countAll("curly fries 123!"))
|
||||
Loading…
Reference in a new issue