简单字符串索引和对比

while True:
    try:
        str1 = str(input())
        cha = str(input())

        k = 0

        if(ord(cha) >= 65 and ord(cha) <= 90):
            for i in str1:
                if(ord(i) >= 65 and ord(i) <= 90):
                    if(ord(i) == ord(cha)):
                        k += 1
                if(ord(i) >= 97 and ord(i) <= 122):
                    if(ord(i) - 32== ord(cha)):
                        k += 1
        if(ord(cha) >= 97 and ord(cha) <= 122):
            for i in str1:
                if(ord(i) >= 65 and ord(i) <= 90):
                    if(ord(i) + 32 == ord(cha)):
                        k += 1
                if(ord(i) >= 97 and ord(i) <= 122):
                    if(ord(i) == ord(cha)):
                        k += 1

        print(k)
    except:
        break