Skip to content
Advertisement

Turn python list into lowercase

I tried every method I could find online but non of them worked. Can someone help me to turn everything in lista lowercase. I try to find duplicates in it but it doesn’t count a lowercase and an uppercase character as duplicate.

from sys import stdin, stdout

def main():
    n = int(stdin.readline())
    iso = 0
    if n <= 0:
        print("Nope")
    else:
        lista = []
        m = n
        while m != 0:
            lista.append(stdin.readline())
            m -= 1
        l = 0
        
        while l < n:
            lst = list(lista[l])
            bol = False
            if " " in lst:
                lst.remove(" ")
            if "n" in lst:
                lst.remove("n")
            for i in lst:
                if lst.count(i) < 3:
                    bol = True
            if bol == True:
                iso += 1
            l += 1

    stdout.write(str(iso))

main()

Advertisement

Answer

While reading in the inputs you can do:

while m != 0:
    read_in_string = stdin.readline()
    lista.append(read_in_string.lower())
    m -= 1

To make the things in lista lower case

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