Counting lowercase and uppercase letters in a string in Python I am writing a program to count the number of uppercase and lowercase letters in a string. I came up with something that works, but as I am still a beginner I have a feeling writing the code this way is probably considered "clumsy."

Here is what I have: 

stri = input("Give me a phrase:")
stri_up = 0
stri_lo = 0
for i in stri:
    if i.isupper():
        stri_up += 1
    if i.islower():
        stri_lo += 1
print("The number of uppercase letters in your phrase is:", stri_up)
print("The number of lowercase letters in your phrase is:", stri_lo)


Output:

Give me a phrase: tHe Sun is sHininG
The number of uppercase letters in your phrase is: 4
The number of lowercase letters in your phrase is: 11


I would like to learn how to write neat, beautiful code so I am wondering if there is a more efficient and elegant way to code this.
Your code is mostly fine. I'd suggest more meaningful names for variables, e.g. i is typically a name for integer/index variables; since you're iterating over letters/characters, you might choose c, char, let, or letter. For stri, you might just name it phrase (that's what you asked for from the user after all). You get the idea. Make the names self-documenting.

Arguably you could make it look "prettier" by performing a single pass per test, replacing:

stri_up = 0
stri_lo = 0
for i in stri:
    if i.isupper():
        stri_up += 1
    if i.islower():
        stri_lo += 1


with:

stri_up = sum(1 for let in stri if let.isupper())
stri_lo = sum(1 for let in stri if let.islower())


That's in theory less efficient, since it has to traverse stri twice, while your original code only does it once, but in practice it's likely faster; on the CPython reference interpreter, sum is highly optimized for this case and avoids constructing a bunch of intermediate int objects while summing.