Skip to content

Commit fa8e734

Browse files
committed
Another way to code CountMillionCharacter.py in a single line
1 parent f4971c8 commit fa8e734

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

CountMillionCharacter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@
289289
Exeunt'''
290290
count = { }
291291
for character in info.upper():
292-
count.setdefault(character, 0)
293-
count[character] = count[character]+1
292+
count[character] = count.get(character,0)+1
294293

295294
value = pprint.pformat(count)
296295
print(value)

0 commit comments

Comments
 (0)