Skip to content

Commit cd9c168

Browse files
committed
Update 100 python exercises - ex14.py
1 parent 264bad4 commit cd9c168

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
ze
1+
# Question 14
2+
# Level 2
3+
#
4+
# Question:
5+
# Write a program that accepts a sentence
6+
# and calculate the number of upper case letters and lower case letters.
7+
8+
# Suppose the following input is supplied to the program:
9+
# Hello world!
10+
# Then, the output should be:
11+
# UPPER CASE 1
12+
# LOWER CASE 9
13+
14+
import re
15+
16+
test_string = "Hello World! WORLD And whatever the hell that MEANS"
17+
18+
split = ''.join(re.split(r'\W+', test_string))
19+
20+
upper = 0
21+
lower = 0
22+
23+
for p in split:
24+
if p.isupper():
25+
upper += 1
26+
elif p.islower():
27+
lower += 1
28+
29+
30+
print upper
31+
print lower

0 commit comments

Comments
 (0)