0

have a scenario

df has 5 rows

for i in range(len(df)):
    print ("\t", i, "Time")

need the output to look like

 0 Time
      1 Time
           2 Time
                3 Time
                     4 Time

How do we make python add the tabs depending on the counter value? Is there a way to do this?

1
  • You can multiply the tab by i like so: print ("\t" * i, i, "Time") Commented Jun 4, 2020 at 5:28

2 Answers 2

1

You could try multiplying of string which would give i no of tabs:

for i in range(len(df)):
    print ("\t"*i, i, "Time")
Sign up to request clarification or add additional context in comments.

Comments

1

Simple change:

for i in range(len(df)):
    print ("\t"*i, i, "Time")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.