Skip to content

Instantly share code, notes, and snippets.

@zmariscal
Last active August 29, 2015 14:16
Show Gist options
  • Save zmariscal/ef0045ddc37f6d34b720 to your computer and use it in GitHub Desktop.
Save zmariscal/ef0045ddc37f6d34b720 to your computer and use it in GitHub Desktop.
make a list of 5 things you're grateful for
from sys import argv
from os.path import exists
script, filename = argv
print "What are five things you're grateful for today?"
print "First:"
First = raw_input("> ")
print "Second:"
Second = raw_input("> ")
print "Third:"
Third = raw_input("> ")
print "Fourth:"
Fourth = raw_input("> ")
print "Fifth:"
Fifth = raw_input("> ")
print "These are things things you're grateful for on:"
print "1.%s\n2.%s\n3.%s\n4.%s\n5.%s\n" % (First, Second, Third, Fourth, Fifth)
f = open('grateful.txt', 'a')
f.write("1. %s\n2. %s\n3. %s\n4. %s\n5. %s\n" % (First, Second, Third, Fourth, Fifth))
f.write("\n==============================================\n")
f.close()
@perryism
Copy link

perryism commented Mar 2, 2015

filename is not used

@perryism
Copy link

perryism commented Mar 2, 2015

line 26, check out the usage of 'with'. see the example at the bottom. http://effbot.org/zone/python-with-statement.htm

@perryism
Copy link

perryism commented Mar 2, 2015

Also, consider using loops to make your code clearer.

@perryism
Copy link

perryism commented Mar 2, 2015

I don't think line 2 from os.path import exists is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment