Skip to content

Instantly share code, notes, and snippets.

@logankilpatrick
Created January 2, 2022 15:31
Show Gist options
  • Select an option

  • Save logankilpatrick/9334e6f92539e4519a27b0ee20952796 to your computer and use it in GitHub Desktop.

Select an option

Save logankilpatrick/9334e6f92539e4519a27b0ee20952796 to your computer and use it in GitHub Desktop.
# Mad Libs in Julia
# Source: https://github.com/logankilpatrick/10-Julia-Projects-for-Beginners
function play_mad_libs()
print("Enter a verb (action): ")
verb1 = readline()
print("Enter an adjective (descriptive word): ")
adj1 = readline()
print("Enter a noun (person place or thing): ")
noun1 = readline()
print("Enter another noun (person place or thing): ")
noun2 = readline()
print("Enter a catchphrase (something like 'hands up!'): ")
phrase1 = readline()
base_sentence = "John $verb1 down the street one night, playing with his $adj1 $noun1. When all of a /
sudden, a $noun2 jumped out at him and said $phrase1"
print("\n\n", base_sentence)
end
play_mad_libs()
@OlgaEle
Copy link
Copy Markdown

OlgaEle commented Mar 23, 2022

There is something weird. I am trying to run my function and I have a problem with the readline() and print() as I have with your code too. The user needs to know what to put in the input, so it is needed for the print phrase to be shown first. But, when I run the code in the jupyter notebook, it shows me only the inputs. When I type the inputs, the function run and print:
Firstly: My inputs
Secondly: The print phrases
Thirdly: The base sentence
image
(The same for the five inputs)
image

@logankilpatrick
Copy link
Copy Markdown
Author

logankilpatrick commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment