You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
575 B
Python
21 lines
575 B
Python
from random import randint
|
|
|
|
def randomline(filename):
|
|
with open(filename, "r") as file:
|
|
print("Reading from file " + filename)
|
|
lines = file.readlines()
|
|
seed = len(lines) - 1
|
|
rando = randint(0, seed)
|
|
theline = (lines[rando])[:-1]
|
|
return theline
|
|
|
|
if __name__ == "__main__":
|
|
filename = str(input("Filename:\n"))
|
|
want = True
|
|
while want:
|
|
print("\n→ " + randomline(filename) + "\n")
|
|
promp = str(input("Another? [Y/n]\n"))
|
|
if promp == "n":
|
|
want = False
|
|
print("\n… Exiting")
|