Last active
December 28, 2015 07:29
-
-
Save Tehnix/7464493 to your computer and use it in GitHub Desktop.
Random Facts
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
| from sys import argv | |
| from urllib2 import urlopen | |
| from os.path import exists | |
| URL = "http://numbersapi.com/random" | |
| SCRIPT, TO_FILE = argv | |
| print "Top 5 Facts of The World" | |
| with open(TO_FILE, 'w') as out_file: | |
| for n in range(5): | |
| data = urlopen(URL).read() | |
| print "\n%s). %s " % (n+1, data) | |
| out_file.write(data + '\n') | |
| print "\nNow, let us save the facts to a file for future use." | |
| print "Alright, facts are saved in the repo." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment