File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ def print_without_spaces (some_str ):
2+ flag = 0
3+ other_str = ""
4+ for i in some_str :
5+ if flag == 0 and i != " " :
6+ other_str += i
7+ elif i == " " :
8+ flag = 1
9+ elif flag == 1 and i != " " :
10+ flag = 0
11+ i = i .upper ()
12+ other_str += i
13+
14+ return other_str
15+ def print_with_spaces (some_str ):
16+ flag = 0
17+ other_str = ""
18+ for i in some_str :
19+ if i >= "A" and i <= "Z" :
20+ flag = 1
21+
22+ if flag == 0 and i != " " :
23+ other_str += i
24+
25+
26+ if flag == 1 :
27+ i = i .lower ()
28+ flag = 0
29+ other_str += " "
30+ other_str += i
31+
32+ other_str = other_str [1 ].capitalize ()+ other_str [2 :]
33+
34+ return other_str
35+
36+
37+ some_str = input ("Enter the string : " )
38+ some_str = print_without_spaces (some_str )
39+ print (some_str )
40+ print (print_with_spaces (some_str ))
41+
You can’t perform that action at this time.
0 commit comments