User Input

Back to Curriculum Index


  • Prompt a user to enter an input value and use that value in your program

Getting User Input

Our programs haven’t been very exciting so far because we already know what will happen just by looking at the code. What if your program incorporated input from the user?


  1. Read the code below and guess what it will do.
  2. Run the program. It’s interactive, so be ready to type in your answers.

Try It: Modify your MadLib!

Go back to your MadLib and add code so that the MadLib can be played repeatedly through the console. Make sure to add prompts and use gets.chomp to get a user's response.

While working through this challenge, pay attention to these programmer skills: 1) keyboard shortcuts (specifically for copy and paste!), and 2) reading error messages.

🌶Spicy Challenge🌶

Are there any inputs that should be screamed at the user? If so, can you use a Ruby method to capitalize all of the letters of that input? If you aren't sure where to start, check out this resource for a strategy on how to do that.

Back to Curriculum Index