Repeat a string: Difference between revisions

Line 1,920:
the other way also works:
<lang python>5 * "ha" # ==> "hahahahaha"</lang>
 
=== Using a Function ===
<lang python>def repeat(s, times):
return s * times
 
print(repeat("ha", 5))</lang>
{{Out}}
<pre>hahahahaha</pre>
 
=== Using Lambda ===
<lang python>x = lambda a: a * 5
print(x("ha"))</lang>
{{Out}}
<pre>hahahahaha</pre>
 
=={{header|Quackery}}==