I have a 2D array like this:
[["Hello", "World"],
["How", "are", "you?"],
["Bye" "World"]]
And I would like it to be put into a text file like this:
Hello World
How are you?
Bye World
I have no idea how to do this, please can someone help.
>Solution :
Is this what you are looking for?
text = [["Hello", "World"],
["How", "are", "you?"],
["Bye", "World"]]
with open('test.txt', 'w+') as f:
for outer in text:
for i, inner in enumerate(outer):
if i == (len(outer) - 1):
f.write(f'{inner}')
else:
f.write(f'{inner} ')
f.write('\n')