File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 GITHUB.COM/MAYUR200
1212
1313"""
14- import re
1514
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]+" )
1915
20-
21- def swap_case (sentence ):
16+ def swap_case (sentence : str ) -> str :
2217 """
2318 This function will convert all lowercase letters to uppercase letters
2419 and vice versa.
@@ -30,13 +25,13 @@ def swap_case(sentence):
3025 for char in sentence :
3126 if char .isupper ():
3227 new_string += char .lower ()
33- if char .islower ():
28+ elif char .islower ():
3429 new_string += char .upper ()
35- if regexp . search ( char ) :
30+ else :
3631 new_string += char
3732
3833 return new_string
3934
4035
4136if __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