File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 13
13
"""
14
14
import re
15
15
16
- # This re.compile() function saves the pattern from 'a' to 'z' and 'A' to 'Z' into 'regexp' variable
16
+ # This re.compile() function saves the pattern from 'a' to 'z' and 'A' to 'Z'
17
+ # into 'regexp' variable
17
18
regexp = re .compile ("[^a-zA-Z]+" )
18
19
19
20
20
21
def swap_case (sentence ):
21
22
"""
22
- This function will convert all lowercase letters to uppercase letters and vice versa.
23
+ This function will convert all lowercase letters to uppercase letters and
24
+ vice versa.
25
+
23
26
>>> swap_case('Algorithm.Python@89')
24
27
aLGORITHM.pYTHON@89
25
28
"""
26
29
new_string = ""
27
30
for char in sentence :
28
- if char .isupper () == True :
31
+ if char .isupper ():
29
32
new_string += char .lower ()
30
- if char .islower () == True :
33
+ if char .islower ():
31
34
new_string += char .upper ()
32
35
if regexp .search (char ):
33
36
new_string += char
You can’t perform that action at this time.
0 commit comments