Reading files Activity
Consider the following: link
In this repl there is a text file babynames.txt contains a list of the 1,000 most popular boy and girl names in the United States for the year 2012 as compiled by the Social Security Administration.
This is a space-delimited file of 1,000 entries in which the rank is listed first, followed by the corresponding boy name and girl name. The most popular names are listed first and the least popular names are listed last. For example, the file begins with
1 Jacob Sophia
2 Mason Emma
3 Ethan Isabella
This indicates that Jacob is the most popular boy name and Sophia is the most popular girl name. Mason is the second most popular boy name and Emma is the second most popular girl name.
Write a program that allows the user to input a name. The program should then read from the file and search for a matching name among the girls and boys. If a match is found, it should output the rank of the name. The program should also indicate if there is no match. The output should be written both to the screen and to a file.
For example, if the user enters the name “Justice”, then the program should output (to the screen and a file):
Justice is ranked 519 among boys.
Justice is ranked 518 among girls.
if the user enters the name “Walter”, then the program should output:
Walter is ranked 376 among boys.
Walter is not ranked among the top 1000 girl names.
