1

How do I make a string repeat itself for example:

instead of writing print ('---------------------------') how do I make it something like print ('-') * 60?

1
  • Sorry, you can only pick one answer as accepted. Pick the one that you feel helped you the most. Commented Nov 11, 2013 at 17:31

2 Answers 2

6

You were so close:

>>> print('-' * 60)
------------------------------------------------------------

You need to multiply the str value, not the return value of the print() function.

Sign up to request clarification or add additional context in comments.

Comments

2

You were very close - it's

print "-" * 60

In Python 2, in Python 3, it's

print ("-" * 60)

2 Comments

This would work on Python 2, but not on Python 3. The OP must be using Python 3 however, as print ('-') * 60 would work just fine on Python 2.
@MartijnPieters Yup, just realized that.

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.