Add files
This commit is contained in:
commit
6549deda7b
9 changed files with 1092 additions and 0 deletions
20
randomline.py
Normal file
20
randomline.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
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")
|
Loading…
Add table
Add a link
Reference in a new issue