Python Forum

Full Version: Find first letter from a list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. I have function that finds first letter in all words from list. And I want to count all lower cases. I don't understand why quantity updates only once.
arr=[["Hello","how","are","you"],["I","am","fine"]
def first_letter(x):
    abc = "abcdefghijklmnopqrstuvwxyz"
    quantity=0
    for j in range(0,len(x)):
        letter= x[j][1]
        if x[j][1] in abc:
            quantity=+1
            
            
    print(quantity)
Because you are using '=+1' (set to positive one) instead of '+=1' (add one in place).
(Nov-27-2019, 10:52 PM)ichabod801 Wrote: [ -> ]Because you are using '=+1' (set to positive one) instead of '+=1' (add one in place).
Thanks stupid mistake, maybe you know THE best way how to find if second word, third letter is UPPERCASE?
words[1][2].isupper()