The Force is Strong with this one [Jan. 27, 2012, 4:16 p.m.]
Your script is running smoothly and looking lovely! Congratulations.
There's one small modification we could make to the script so that it could be useful for any search term. That's a lot of search terms :) And it certainly makes the script a lot more flexible.
You have two options for implementing this functionality. Command line arguments and user prompt.
Command Line Arguments
The first is to make your program take an argument when you first run it from the command line. Instead of
$ ruby myscript.rb
you would run
$ ruby myscript.rb searchterm
(and similarly for python).
When you pass arguments to a script in this way, they are stored in a list named, in both languages, ARGV (for historical reasons). In Ruby, ARGV is a global array, and the first argument to your script is stored in ARGV[0].
In Python, in order to access the ARGV variable you must import the sys module (import sys). The first program argument is stored in sys.ARGV[1].
User Prompt
A user prompt is a line of code that prompts the user for some kind of input. The program will wait until the user hits enter before continuing. Both Ruby and Python have a simple way of doing this.
Of course, you want some descriptive text to accommodate the prompt, otherwise the user might not be clear what the program is waiting for. If needed, insert an appropriate print statement before the prompt to explain what you would like from the user.
For python, read about the raw_input function. For ruby, you'll want to look into the gets function. See for example this reference.
Make note of how the input is stored, and remember the variable name that you chose so you can use it as described below.
Tweaking your API Call
Now that you have your search_term variable, you'll need to modify the api_call string (remember, from task 5?) so that the search term is inserted into the url. You can do this either by using string formatting, as we did in the previous task, or you can use string concatenation.
Read about string concatenation or formatting if you need to, and then make the necessary change to your script. Once you have inserted the search_term variable into the api_call string, everything else is the same. Not so bad, is it?
Did you do any error checking to see if the user submitted a value before retrieving it? What happens if the user doesn't give an argument? Where does your program fail? How could you make it more robust?
Post the approach you took to the comments, and share any particularly good resources you came across. You don't have to implement error checking for this challenge, but it's good practice to start thinking about it! (And you are, of course, most welcome to implement it if you like).