-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path50.py
49 lines (38 loc) · 1.32 KB
/
50.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#Write a function called remove_capitals. remove_capitals
#should accept one parameter, a string. It should return a
#string containing the original string with all the capital
#letters removed. Everything else should be in the same
#place and order as before.
#
#For example:
#
# remove_capitals("A1B2C3D") -> "123"
# remove_capitals("WHAT") -> ""
# remove_capitals("what") -> "what"
#
#Remember, capital letters have ordinal numbers between 65
#("A") and 90 ("Z"). You may use the ord() function to get
#a letter's ordinal number.
#
#Your function should be able to handle strings with no
#capitals (return the original string) and strings with all
#capitals (return an empty string). You may assume we'll
#only use regular characters (no emojis, formatting
#characters, etc.).
#Write your function here!
def remove_capitals(string):
new_word = ""
for character in string:
if not 65 <= ord(character) <= 90:
new_word += character
return new_word
#Below are some lines of code that will test your function.
#You can change the value of the variable(s) to test your
#function with different inputs.
#
#If your function works correctly, this will originally
#print:
#123
#eorgia nstitute of echnology
print(remove_capitals("A1B2C3D"))
print(remove_capitals("Georgia Institute of Technology"))