We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#!/bin/python3importosimportsysdefrec(s,p1,p2,lev):ifp2==len(s)andp1!=p2:lev+=1p2=p1=levifp2==p1==len(s):returnelse:forxinrange(p1,p2+1):print(s[x],end="")print(" ")rec(s,p1,p2+1,lev)# Complete the solve function below.defsolve(s):rec(s,0,0,0)returnif__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')t=int(input())fort_itrinrange(t):n=int(input())s=input()result=solve(s)# print(result)fptr.write('\n'.join(result))fptr.write('\n')fptr.close()
why this code is giving error
Traceback (most recent call last):
File "Solution.py", line 37, in
fptr.write('\n'.join(result))
TypeError: can only join an iterable
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Building a List
You are viewing a single comment's thread. Return to all comments →
why this code is giving error Traceback (most recent call last): File "Solution.py", line 37, in fptr.write('\n'.join(result)) TypeError: can only join an iterable