File tree 1 file changed +33
-0
lines changed
Challenge questions/Sofiia2001
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ def formatting (sentence ):
2
+ sentence = list (sentence )
3
+ for symbol in range (len (sentence ) - 1 ):
4
+ if sentence [symbol ] == ' ' :
5
+ sentence [symbol ] = ''
6
+ sentence [symbol + 1 ] = sentence [symbol + 1 ].upper ()
7
+
8
+ sentence = '' .join (sentence )
9
+ return sentence
10
+
11
+
12
+ def formatting_back (sentence ):
13
+ to_return = [sentence [0 ]]
14
+ for symbol in sentence [1 :]:
15
+ if symbol == symbol .upper ():
16
+ to_return .append (' ' )
17
+ to_return .append (symbol .lower ())
18
+ else :
19
+ to_return .append (symbol )
20
+ to_return = '' .join (to_return )
21
+ return to_return
22
+
23
+
24
+ def main ():
25
+ sentence = str (input ('Enter yor string: ' ))
26
+ formatted = formatting (sentence )
27
+ print (f'Formatted: { formatted } ' )
28
+ formatted_back = formatting_back (formatted )
29
+ print (f'Formatted back: { formatted_back } ' )
30
+
31
+
32
+ if __name__ == '__main__' :
33
+ main ()
You can’t perform that action at this time.
0 commit comments