You are viewing a single comment's thread. Return to all comments →
Ok, here is the explanation.
The simple print(*arr[::-1]) is equivalent to:
output_str = ""
inverse_array = arr[::-1]
for element in inverse_array:
output_str = output_str + " " + str(element)
This is why Python has it all.
the challenge is to make the reverse algorithm yourself. you're still relying on just using arr[::-1] instead of actually writing that algorithm yourself.
but it is still showing the same error before using this code
Traceback (most recent call last):
File "solution.py", line 31, in
fptr.write(' '.join(map(str, res)))
TypeError: 'NoneType' object is not iterable