Possible Duplicate:
Python, Printing multiple times,
I’d like to know how to print a string such as “String” 500 hundred times?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use repetition (
*):In this way Python will first create the whole string (
"StringStr...String") in memory and only then will print it.If you don’t want to use so much memory, then you can use a for loop:
end=''is needed to prevent Python from printing end-of-line characters after eachprint.print()at the end is needed to print the end-of-line character after the lastprint.