0
In the below code, why am I getting a syntax error on the last line[file.close()]. In the error message. Pls help
file = open("/usercode/files/books.txt", "r") g = file.readlines() for i in g: if '\n' in i: print((i[0]) + str(len(i)-2)) else: print((i[0] + str(len(i))) file.close()
4 Answers
+ 1
Python.Sorry forgot to mention that đ
+ 1
you could edit the question/tag ;)
the error is just before the mentioned line: mismatch parenthesis in 'else' block ^^
print((i[0]) + str(len(i)))
(but you could avoid i[0] parenthesis)
0
Thanks bro, Came out to be a silly mistake đ