Repeat a string: Difference between revisions
Content added Content deleted
Line 1,797: | Line 1,797: | ||
def repeat(s, times): |
def repeat(s, times): |
||
return s * times</lang> |
return s * times</lang> |
||
=={{header|Python}}== |
|||
<lang python>def repeat(s, times): |
|||
return s * times |
|||
print(repeat("ha", 5))</lang> |
|||
# output: |
|||
# hahahahaha |
|||
=== Using Lambda === |
|||
<lang python>x = lambda a: a * 5 |
|||
print(x("ha"))</lang> |
|||
{{Out}} |
|||
<pre>hahahahaha</pre> |
|||
=={{header|Prolog}}== |
=={{header|Prolog}}== |