Reputation: 13
I wrote the following code and tried to submit it. It works perfectly on my own machine but when I try to test run it on their website, it says there was a runtime error. This is not the first question where I have encountered this but the second. This is not a logical error but something wrong with the syntax or how I am taking the inputs maybe. Please tell me what I'm doing wrong. Thanks in advance.
Screenshot of code with problem statement from the website
Here's the code if you couldn't see the picture:
t = int(input().strip())
for i in range(1, t+1):
n = int(input().strip())
p = input().strip()
res = ""
for c in p:
if c == 'E':
res += 'S'
else:
res += 'E'
print(f"Case #{i}: {res}")
Upvotes: 1
Views: 192
Reputation: 1055
t = int(input().strip())
for i in range(1, t+1):
n = int(input().strip())
p = input().strip()
res = ""
for c in p:
if c == 'E':
res += 'S'
else:
res += 'E'
print("Case #{}: {}".format(i, res))
I'm guessing whatever version google runs is less than 3.6 when f-strings were introduced; verified this works.
Upvotes: 1