Mad Libs: Difference between revisions
Content added Content deleted
m (added related tasks.) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 28: | Line 28: | ||
{{Template:Strings}} |
{{Template:Strings}} |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<lang 11l>V template = ‘<name> went for a walk in the park. <he or she> |
|||
found a <noun>. <name> decided to take it home.’ |
|||
F madlibs(template) |
|||
print("The story template is:\n"template) |
|||
V fields = sorted(Array(Set(re:‘<[^>]+>’.find_strings(template)))) |
|||
V values = input("\nInput a comma-separated list of words to replace the following items\n #.: ".format(fields.join(‘,’))).split(‘,’) |
|||
V story = template |
|||
L(f, v) zip(fields, values) |
|||
story = story.replace(f, v) |
|||
print("\nThe story becomes:\n\n"story) |
|||
madlibs(template)</lang> |
|||
{{out}} |
|||
<pre> |
|||
The story template is: |
|||
<name> went for a walk in the park. <he or she> |
|||
found a <noun>. <name> decided to take it home. |
|||
Input a comma-separated list of words to replace the following items |
|||
<he or she>,<name>,<noun>: She,Monica L.,cockerel |
|||
The story becomes: |
|||
Monica L. went for a walk in the park. She |
|||
found a cockerel. Monica L. decided to take it home. |
|||
</pre> |
|||
== {{header|Ada}} == |
== {{header|Ada}} == |