Last active
June 23, 2019 09:59
-
-
Save eguyd/ba76da01f2f4309f57e8089450bc49e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################## | |
# Author: Guy D. # | |
# Last Day Modified: 6/23/19 # | |
############################## | |
""" Write a program that allows the user to navigate the lines of text in a file. The | |
program should prompt the user for a filename and input the lines of text into a | |
list. The program then enters a loop in which it prints the number of lines in the | |
file and prompts the user for a line number. Actual line numbers range from 1 to | |
the number of lines in the file. If the input is 0, the program quits. Otherwise, the | |
program prints the line associated with that number. """ | |
fileName = input("Enter a File from your computer: ") | |
movies = open(fileName, 'r') | |
# INPUT FILE NAME INTO LIST | |
movies = movies.readlines() | |
selection = list(movies) | |
numMovies = len(movies) | |
# DISPLAY SELECTION WITH COUNTER | |
counter = 1 | |
for line in movies: | |
print(counter, line) | |
counter += 1 | |
while True: | |
numMovies = 0 | |
numMovie = int(input(" SELECT BY ROW NUMBER \n TIP! Enter 1 or 2, 3... \n or \n PRESS 0 to EXIT: ")) | |
if 1 <= numMovie <= numMovies: | |
print("Your Selection: "), numMovie | |
else: | |
if numMovie == 0: | |
print("SEE YOU NEXT TIME! ") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment