How to check if a character is uppercase or lowercase in Pyhton?

Asked

Viewed 1,296 times

0

I have a string any and I need to know the amount of upper and lower case letters in that string. I started sketching something like this:

def contaMaiuscula(string):
    ma = 0
    mi = 0
    for c in string:
        if(c == ????):
            ma = ma+1
        else:
            mi = min +1
    return ma, mi

But how do I know if a character is uppercase or lowercase? Is there a function for this?

1 answer

1


  • Thanks, it worked :) I tried with islower() tbm and it worked

  • @Anacarolinaesteves see on [tour] the best way to say thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.