Skip to content

Commit 1224952

Browse files
Merge pull request #24 from Hemant-60/master
Challange-1
2 parents 7c818bb + dc371b1 commit 1224952

File tree

1 file changed

+41
-0
lines changed
  • Challenge questions/Hemant-60

1 file changed

+41
-0
lines changed

Challenge questions/Hemant-60/c1.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+

0 commit comments

Comments
 (0)