Last active
May 21, 2016 21:07
-
-
Save telmotrooper/62f2745f3aa5d3d2405f5301370eed00 to your computer and use it in GitHub Desktop.
Reads a random message from a file and prints it
This file contains 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
"Reads a random message from a file and prints it" | |
from random import randint | |
with open("antichamber.txt") as file: | |
messages = file.readlines() | |
file_title = messages[0].replace("\n","") | |
random_number = randint(1, len(messages)-1) | |
random_message = messages[random_number].replace("\n","") | |
print("Reading from", file_title) | |
print(random_message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment