FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
All-Algorithms-In-Python/algorithms/strings/change_case.py at master · codeme254/All-Algorithms-In-Python · GitHub
codeme254
/
All-Algorithms-In-Python
Public
forked from
AllAlgorithms/python
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
All-Algorithms-In-Python
/
algorithms
/
strings
/
change_case.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
12 lines (9 loc) · 489 Bytes
Breadcrumbs
All-Algorithms-In-Python
/
algorithms
/
strings
/
change_case.py
Copy path
File metadata and controls
12 lines (9 loc) · 489 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
# Simple function that converts uppercase characters to lowercase and vice versa.
# Author: jotslo
def
change_case
(
string
):
# Iterates through string, if character is lowercase, convert to upper else lower
new_string
=
[
char
.
upper
()
if
char
.
islower
()
else
char
.
lower
()
for
char
in
string
]
# Joins list with an empty string to form the new string and return
return
""
.
join
(
new_string
)
print
(
change_case
(
"Hello, world!"
))
# hELLO, WORLD!
print
(
change_case
(
"TEST"
))
# test
Back
|
FazBrowse Home
|
New Git URL