4

I am trying to have python output something that I can then copy and past into a latex document. I need the output to look like this:

q_{00} q_{01}

etc, I am using this code here, but, is there a way to get the curly bracket to print, the formatted number, and the other curly bracket, without adding whitespace or spaces?

for rows in range(nst):
    print("q_{{0:0=2d}}".format(rows))

which just yields q_{0:0=2d}

Olivier Melançon
  • 21,584
  • 4
  • 41
  • 73
Joseph
  • 301
  • 3
  • 13

1 Answers1

6

{{ unescapes to an uninterpreted {, so you need another {:

for rows in range(nst):
    print("q_{{{0:0=2d}}}".format(rows))

Likewise for the closing }, of course.

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92