在运行python3代码时在Hackerearth上运行时出错NZEC
问题描述:
当我在hackerearth上运行下面的代码时,它给了我运行时错误NZEC。在运行python3代码时在Hackerearth上运行时出错NZEC
t = input()
vow = ["A","a","E","e","I","i","O","o","U","u"]
while t>0:
count_vow = 0
str1 = input()
for i in range(str1):
if i in vow:
count_vow += 1
print(count_vow)
t -= 1
任何排序的帮助,将不胜感激。
答
你期待的第一个输入是一个数值,所以你应该换你input()
呼叫在int()
所以它存储这多项
你有第二个问题是,你叫for i in range(str1)
的str1
是一个字符串,使用range()
是数字。只需使用for i in str1:
t = int(input())
vow = ["A","a","E","e","I","i","O","o","U","u"]
while t > 0:
count_vow = 0
str1 = input()
for i in str1:
if i in vow:
count_vow += 1
print(count_vow)
t -= 1
Test Cases:
# >> denotes input and > denotes output
>> 2
>> nBBZLaosnm
> 2
>> JHkIsnZtTL
> 1
您使用什么输入?什么是错误的堆栈跟踪? – AK47
以下是输入 nBBZLaosnm JHkIsnZtTL –