Is there an solution to print out ascii graphics when the data is on a array?

Viewed 36

I have a set of information in a list a

a = [["*","-","-"],["-","*","-"],["-","-","*"]]

in which I would like to use a code so that my terminal will show:

*--
-*-
--*

I've tried:

print(a)

but it shows only the list

I've also tried:

print(a[0][0], a[1][0], a[2][0])
print(a[0][1], a[1][1], a[2][1])
print(a[0][2], a[1][2], a[2][2])

but it gives me spaces:

* - -
- * -
- - *
2 Answers

You need to join each list on an empty space

for l in a:
  print(''.join(l))
for line in a:
  print(''.join(line))
Related