Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Post the "Do you even lift" one.

Name: Anonymous 2013-09-23 21:22

Do you guys like my program? I did it half assed yesterday but got it right after messing with it a bit more.

import sys
i = int(sys.argv[1])

psth = "Post the " ; qpsth = "\"Post the " ; one = " one" ; qone = " one\"" ; dye = "\"Do you even lift?\""
   
print (psth + qpsth * i + dye + qone * i + one)


http://s11.postimg.org/krhruoju9/Screenshot_9.png

Name: Anonymous 2013-09-24 0:53

You can do this without separate quoted versions of the strings.

Also you've got your base case wrong. I say it makes more sense for n = 0 to print "Do You even lift?" alone, that way n corresponds directly to the number of times the phrase is quoted rather than n + 1 times like in your program.

I've also taken the liberty to upgrade the language used:

n = ARGV.size >= 1 ? Integer(ARGV[0]) : 0
n.times { print("Post the \"") }
print "Do you even lift?"
n.times { print("\" one") }


I'm glad I could be of assistance. Please read your SICP today.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List