Python display string multiple times

I want to print a character or string like ‘-‘ n number of times.

Can I do it without using a loop?.. Is there a function like


..which would mean printing the – 3 times, like this:


Python, Printing multiple times,

How can I repeat a string multiple times, multiple times? I know I can use a for loop, but I would like to repeat a string x times per row, over n rows. For example, if the user enters 2, the output w

How to grep for same pattern multiple times in a string using python?

I am using python to pattern match a string multiple times in a string. Problem: string = ‘The value = 1 The value = 2 The value = 3’ I want to grep only value but my output should be like: [‘value =

Finding a string multiple times in another String – Python

I’m trying to see if a string exists in another string with out using Python’s predefined functions such as find and index.. Right now what my function takes 2 strings as parameters, one is the string

md5 a string multiple times

md5 a string multiple times in Python: def md5(i): return hashlib.md5(i).hexdigest().upper() def md5x3(src): f = hashlib.md5(src).digest() s = hashlib.md5(f).digest() t = md5(s) return t how to imple

Is there any harm to encoding (with the same encoding format) a string multiple times? (in Python)

Is there any harm to encoding a string multiple times in python, with the same encoding format? (i.e, UTF-8)? I have a function that uses another function to get a string from a document, and then ser

Displaying a String Multiple times using * operator [duplicate]

Possible Duplicate: Can I “multiply” a string (in C#)? Is there a simple way to display a String multiple times by using something like str * 2? In other words, is there a way to have: int numTimes

Python: Split string multiple times; nest the data structure

I’m new to python so apologies for the easy questions. I’m certainly missing something which is getting me confused. This has something to do with nesting, splitting, and I’m guessing for loops but i

Python string formatting: reference one argument multiple times

If I have a string like: {0} {1} {1} % (foo, bar) and I want: foo bar bar What do the replacement tokens have to be? (I know that my example above is incorrect; I’m just trying to express my

RegEx Match multiple times in string

I’m trying to extract values from a string which are between << and >>. But they could happen multiple times. Can anyone help with the regular expression to match these; this is a test for

execute python script multiple times

Im not sure about the best way to do this but I have a python script saved as a .py. The final output of this script is two files x1.txt and y1.txt. Basically I want to run this script say 1000 times


The following will work:

print '-' * 3

To print a string 3 times in Python 3.x, in this case the string is “hello”

print(“hello ” * 3)