File tree 1 file changed +4
-9
lines changed
1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change 11
11
GITHUB.COM/MAYUR200
12
12
13
13
"""
14
- import re
15
14
16
- # This re.compile() function saves the pattern from 'a' to 'z' and 'A' to 'Z'
17
- # into 'regexp' variable
18
- regexp = re .compile ("[^a-zA-Z]+" )
19
15
20
-
21
- def swap_case (sentence ):
16
+ def swap_case (sentence : str ) -> str :
22
17
"""
23
18
This function will convert all lowercase letters to uppercase letters
24
19
and vice versa.
@@ -30,13 +25,13 @@ def swap_case(sentence):
30
25
for char in sentence :
31
26
if char .isupper ():
32
27
new_string += char .lower ()
33
- if char .islower ():
28
+ elif char .islower ():
34
29
new_string += char .upper ()
35
- if regexp . search ( char ) :
30
+ else :
36
31
new_string += char
37
32
38
33
return new_string
39
34
40
35
41
36
if __name__ == "__main__" :
42
- print (swap_case (input ("Please input sentence:" )))
37
+ print (swap_case (input ("Please input sentence: " )))
You can’t perform that action at this time.
0 commit comments