-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapitalize.py
More file actions
34 lines (28 loc) · 738 Bytes
/
capitalize.py
File metadata and controls
34 lines (28 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# https://www.hackerrank.com/challenges/capitalize/problem?isFullScreen=true
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(s):
return_s = ""
uppercase_true = True
for i in s:
if (i != " ") and not i.isnumeric() and uppercase_true :
return_s += i.upper()
uppercase_true = False
elif i == " ":
return_s += i
uppercase_true = True
else:
return_s += i
uppercase_true = False
return return_s
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = solve(s)
fptr.write(result + '\n')
fptr.close()