Solution 1

def neutralize_uppercase(stringy):
    count = 0
    while count < len(stringy):
        if stringy[count] == stringy[count].upper():
            stringy = ""
        count += 1
    return stringy

No Uppercase Allowed

Complete the function neutralize_uppercase so that it returns stringy the same as it was received if there are no capital letters in it or an empty string "" if there were. You need to use a while loop to go through each letter of the string one at a time to check for uppercase letters.


# String has no uppercase letters so returns input string unchanged
>>>  neutralize_uppercase("snitch") == "snitch"

# String has uppercase letters so returns empty string
>>>  neutralize_uppercase("eXpelliarMus")

Hint: You'll probably need to use len() to figure out your condition to stop looping through the string. You'll also need to use upper().

Test Cases

test no uppercase - Run Test

def test_no_uppercase():
    assert neutralize_uppercase("snitch") == "snitch"

test has uppercase - Run Test

def test_has_uppercase():
    assert neutralize_uppercase("eXpelliarMus") == ""
def neutralize_uppercase(stringy): pass