-1

I've been searching this but I can't find it. I want to view a list of commands in an organized fashion, so that this:

Comandos = ["1: Imprime lista de opciones", "2: Abre la calculadora de dinero"]

pprint(Comandos)

Gets printed like this:

1: Imprime lista de opciones
2: Abre la calculadora de dinero.

2 Answers2

3

You do not need pprint, you can simply join them together and print them:

print('\n'.join(Comandos))
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
0

As @willem-van-onsem said, you can simply join and it will be all done.

However if you need HAVE TO to use pprint you can do this as such:

pprint(a,width=max(len(a[0]),len(a[1]))*2)

Mind you, it is not optimal (nor recommended) solution.

And more general approach :

pprint(a,width=len((max(a, key=len))*2))

Additional note: This appropach will not work when n (n>1) of shortest strings sum to the longest (on length).

MaLiN2223
  • 1,290
  • 3
  • 19
  • 40