Skip to content

Commit bbf21ca

Browse files
committed
2 parents 8ca8a89 + ab606cd commit bbf21ca

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: strings/swap_case.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@
1313
"""
1414
import re
1515

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
1718
regexp = re.compile("[^a-zA-Z]+")
1819

1920

2021
def swap_case(sentence):
2122
"""
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+
2326
>>> swap_case('Algorithm.Python@89')
2427
aLGORITHM.pYTHON@89
2528
"""
2629
new_string = ""
2730
for char in sentence:
28-
if char.isupper() == True:
31+
if char.isupper():
2932
new_string += char.lower()
30-
if char.islower() == True:
33+
if char.islower():
3134
new_string += char.upper()
3235
if regexp.search(char):
3336
new_string += char

0 commit comments

Comments
 (0)