DEV Community

Discussion on: Daily Challenge #270 - Fix String Case

Collapse
 
ritheeshbaradwaj profile image
Ritheesh
def solve(inp):
    lower_count = 0
    length = len(inp)
    for i in inp:
        if i.islower():
            lower_count += 1
    if 2*lower_count >= length:
        return inp.lower()
    return inp.upper()

Tests:
solve("code") = "code"
solve("CODe") = "CODE"
solve("COde") = "code"
solve("Code") = "code"

Please let me know if there are any changes to be made.