NZEC PYTHON

#D:\Python32
import string
t=1
st=‘fd’
t=input()
while(int(t) > 0):
st=input()
ctr=0
i=0
l=len(st)
for i in range(0,l):
if st[i]==‘A’ or st[i]==‘D’ or st[i]==‘P’ or st[i]==‘O’ or st[i]==‘Q’ or st[i]==‘R’:
ctr=ctr+1
elif st[i]==‘B’:
ctr=ctr+2
print(ctr)

why if the above code showing nzec while running for Holes in the text

Could be one of two issues.
t = int(input()) // this is required, it is mandatory to do this.

Secondly, put all the imput() statements in a try-except block. http://discuss.codechef.com/questions/434/python-nzec-runtime-error

This is python 2.7 i presume. The main error is you are using input() for taking string as input but input expects an integer argument. replace input() with raw_input() when you take string input. also i think you have forgotten to decrement t in your while loop!! rest all looks fine

input is for reading integers and not strings.

why you define st=‘fd’?
and instead of st=input() , use st=raw_input().

Use raw_input() function instead of input() in line 7.

1 Like