[英]Runtime Error NZEC on Hackerearth while running python3 code
我在hackerearth上运行以下代码,这给了我Runtime Error 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)
调用for i in range(str1)
, str1
是字符串,而使用range()
则是数字。 只需for i in str1:
使用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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.