View Single Post
Old Mar 28th, 2005, 12:58 PM   #1
dezza
Newbie
 
dezza's Avatar
 
Join Date: Mar 2005
Location: Denmark
Posts: 16
Rep Power: 0 dezza is on a distinguished road
Send a message via ICQ to dezza Send a message via MSN to dezza
Thumbs up "How to think like a computer scientist - Python"

Hello everyone I am glad that I found this forum by searching trough Google, hope you can help me out in my attempt to fully understand Python.

I have followed the guide "How To Think Like a Computerscientist - Python" and i've come to this place where I can't think of any creative ways to do what the exercise says:

As an exercise, modify the program to fix this error.

(It's the Jack, Kack, Lack, Mack, Nack, Ouack, Pack, and Quack Duckling exercise thing I am working on)

http://www.ibiblio.org/obp/thinkCSpy/chap07.htm#3

I know that I could simply just make several of the example code in alphabetical order:

prefixes = "JKLMNOPQ"
suffix = "ack"

for letter in prefixes:
  print letter + suffix

like ..

prefix1 = "JKLMN"
prefix2 = "O"
prefix3 = "P"
prefix4 = "Q"
suffix1 = "ack"
suffix2 = "uack"

for letter in prefix1:
  print letter + suffix1

for letter in prefix2:
  print letter + suffix2

for letter in prefix3:
  print letter + suffix1

for letter in prefix4:
  print letter + suffix2

But I am not sure if that is what is meant to be done in this guide? Maybe someone who have done this guide can answer this?

Once again, I hope this forum will grow big and become the main spot for programming help..
dezza is offline   Reply With Quote