简体   繁体   中英

list index out of range error in python , why does it happen?

''' Read input from STDIN. Print your output to STDOUT ''' #Use input() to read input from STDIN and use print to write your output to STDOUT

def main():

t = int(input())
strr =[]
vcount =0
ccount =0
for i in range(t):
    s = input()
    strr[i].append(s)
for i in strr:
    for j in i:
        if j == 'a' or 'e' or 'i' or 'o' or 'u':
            vcount += 1
        else:
            ccount +=1
    print(vcount,ccount,vcount*ccount)

main()

error while uploading into strr, plz correct the code

This will probably will not through that error

t = int(input())
strr =[]
vcount =0
ccount =0
for i in range(t):
    s = input()
    strr.append(s)
for i in strr:
    for j in i:
        if j == 'a' or 'e' or 'i' or 'o' or 'u':
            vcount += 1
        else:
            ccount +=1
    print(vcount,ccount,vcount*ccount)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM