Create program that asks the user for the name of a file


Problem

Create program that asks the user for the name of a file. The program should display only the first five lines of the file's contents. If the file contains less than five lines, it should display the file's entire contents.

Comments!!! Comments!!! Comments!!!
Comments should be indented as the program lines.
Program should run without any syntax or run-time errors.
Have the main() function.

You need an input file that is saved in the same folder where your program is located. You can download the input file names.txt from Week 11-12 content.

A while loop is recommended to read the lines as long as the line is NOT empty AND the line number (counter) is less than or equal to 5.

Read the data until the line is empty.

Use a counter to keep the count of data.
Use the readline( ) function to read a line at a time from the input file.
Use the rstrip( ) function to strip the additional new line ('n') between the names.

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Create program that asks the user for the name of a file
Reference No:- TGS03268342

Expected delivery within 24 Hours