Homework 6
The deadline is Sunday, the 17th of October, 23:59 (Estonian time).
Exercise 1. Name in URL
Write a program that reads URLs of Tartu University users' webpages from a file called urls.txt and outputs the usernames. The solution should have a function called find_name
that takes one parameter (URL) and returns the name (you can reuse the solution of the previous homework to find a user name from an URL and make it as a function). You should create the file urls.txt yourself.
If the file urls.txt contains the following lines:
http://www.ut.ee/~koit/KT/index_eng.html http://www.ut.ee/~vilo/ http://www.ut.ee/~kiho/
then the output of the program should be
koit vilo kiho
Exercise 2. Numbered lines
Write a program which prompts the user for the file name and outputs all the lines from the file with its line number. Make sure that the program works nicely with all the files which exist and do not exist (use try-except).
If the content of the file names.txt is as follows:
Jon Snow Arya Stark Tyrion Lannister Eddard Stark Melisandre
then the program output is as follows:
Enter the file name: names.txt 1. Jon Snow 2. Arya Stark 3. Tyrion Lannister 4. Eddard Stark 5. Melisandre
Go to Moodle and upload your solution into Homework 6.