Skip to content
Advertisement

function which purpose is to print lowercase symbols with some conditions

My task “For this challenge, define a function called quieter_please that takes in one string argument and checks if the string is all uppercase. If it is all upper case, convert the string to all lowercase and return this lowercased string. If the argument string is not all uppercase, return this same string, unmodified” When I type any word with uppercase symbols, the output is word in lowercase symbols. How can I change my code in order to complete the task?

str="Hello"
def quieter_please(str):
    if str.islower==False and str.isupper==False:
        c=str
        return c
    elif str.islower==True and str.isupper==False:
        b=str
        return b   
    else:
        d=str.lower()
        return d
print(quieter_please(str)) 
      
``'

Advertisement

Answer

You need to add () after islower and isupper functions it would be islower() and isupper()

str="Hello"
def quieter_please(str):
    if str.islower()==False and str.isupper()==False:
        c=str
        return c
    elif str.islower()==True and str.isupper()==False:
        b=str
        return b   
    else:
        d=str.lower()
        return d
print(quieter_please(str))
Hello

This was the reason it was skipping first 2 conditions.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement