What is an efficient way to repeat a string to a certain length? Eg: repeat('abc', 7) -> 'abcabca' Here is my current code: def repeat(string, length): cur, old =...
In Python, where [2] is a list, the following code gives this output: [2] * 5 # Outputs: [2,2,2,2,2] Does there exist an easy way to do this with...
In Perl I can repeat a character multiple times using the syntax: $a = "a" x 10; // results in "aaaaaaaaaa" Is there a simple way to accomplish this...