A Starter Template

The main idea of the project is to be able to find a zip code to a certain city with a user input. It’s a great way to just practice the basics.

City Info

Is a hash with a list with the names of cities & their zip codes.

The next thing I did was create a method to get the city by name.

Here I would need to figure out a way to list out all the keys.

I then created another method to get the zip code and return a city associated with it.

Here I need to figure out how to return the key value hash that will be passed in.

So far I have two methods. One to get the city and the other to get the zipcode.

I used a basic loop. Infinite loops are not a good way to do it. However, since this is just a starter template I have used a basic

I added a puts statement. Asking for users input.

This next line of code calls the method ‘get_city_name’ which takes in the ‘city info’(the list of cities & zip). Then asks for users input.

I’ve assigned a variable prompt to user input.

In a case where a user inputs an invalid city, I have created an If Else Statement.

This will take in the prompt and then interpolate the zip code associated with the ‘city info’ hash and given prompt.

In the end it should look like this: