Keep getting a runtime error while submitting NITIKA

n = int(input())

while n > 0  :
  k = raw_input()
  
  if k.find(" ") != -1: 
  
    final = str(k[0].upper() + '.')
    
    
    for i in range(len(k)) :
      if (k[i] == ' ') & (k[i:].find(" ")):
        final += k[i+1].upper() + ". "
      else:
          if(k[i] == ' '):
            final += k[i+1].upper() + k[i+2:].lower()
          
        
    n -= 1
      
    print final[0:len(final)]
  else :
    print  k[0].upper() + k[1:].lower()

I’ve tested this out personally, I don’t get why on submission i get a run time error.
Can anyone please clarify? :slight_smile: Thanks.

The line n-=1 is written in the if block. So n will be decremented only when the execution goes in the if block.

That is why it you are getting a run time error.

1 Like
//