summaryrefslogtreecommitdiff
path: root/day1/exercise
diff options
context:
space:
mode:
authorSantosh G. Vattam2009-10-27 16:06:08 +0530
committerSantosh G. Vattam2009-10-27 16:06:08 +0530
commit5be855777639574e36549e478e2078b62b610e22 (patch)
tree05c270e0786a88142936692f172f2c1557982cba /day1/exercise
parentefcb609f1e6d848596d43771e745c43a632b17f9 (diff)
parentebe7c77cfaf0f63de4162f94b3ae6f5ceca4bd10 (diff)
downloadworkshops-5be855777639574e36549e478e2078b62b610e22.tar.gz
workshops-5be855777639574e36549e478e2078b62b610e22.tar.bz2
workshops-5be855777639574e36549e478e2078b62b610e22.zip
Manual merge of branches.
Diffstat (limited to 'day1/exercise')
-rw-r--r--day1/exercise/kwfreq.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/day1/exercise/kwfreq.py b/day1/exercise/kwfreq.py
index 0da7ff3..e905e26 100644
--- a/day1/exercise/kwfreq.py
+++ b/day1/exercise/kwfreq.py
@@ -1,5 +1,5 @@
import keyword
-f = open('/path/to/file')
+f = open('amicable.py')
freq = {}
for line in f:
@@ -7,8 +7,10 @@ for line in f:
for word in words:
key = word.strip(',.!;?()[]: ')
if keyword.iskeyword(key):
- value = freq[key]
- freq[key] = value + 1
+ if key in freq:
+ freq[key] += 1
+ else:
+ freq[key] = 1
print freq