Why the below code gets Run time Error?

t = int(input().strip())

for _ in range(t):
n = int(input().strip())
if n == 1:
print(3)
else:
x = (10 ** (n-1)) + 5

    print(x)

Hey man, your code has a small issue—indentation. Python is kinda strict about it, and since your if and else aren’t properly inside the loop, it’s throwing a runtime error.

Here’s the fixed version:

python

CopyEdit

t = int(input().strip())

for _ in range(t):
    n = int(input().strip())  

    if n == 1:
        print(3)  
    else:
        x = (10 ** (n-1)) + 5  
        print(x)

Python needs everything inside the loop to be indented correctly, and since yours wasn’t, it got confused and crashed. Fix the indentation, and it should work just fine!