[Tutor] small program

bob gailer bgailer at gmail.com
Fri Oct 2 17:38:35 CEST 2009


Andrius wrote:
> Hi!
>
> There are interesting online course
> http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-00Fall-2008/LectureVideos/index.htm
> where I'm trying to learn Python.
> Looks quite interesting and I would like to create a program which
> should repeat a simply string several times with list number before.
> Like "1. Wanna more. 2. Wanna more. ..."
> Suppose to a loop here repeating, say x times. Should it look like that:
>
> y="Wanna more. "
> x=1
> x=x+d:
> d=<100
> print d+y
>
> How to create a program for such kind of task?
>   

Pardon my skepticism - I'm guessing you are taking the course and this 
is homework. We prefer not to do your homework for you. If it is not 
homework - we prefer not to write programs for you.

Unfortunately Benno gave you a solution.

If you want to learn Python read on:

In regard to the above code - did you try to run it? That is step one. 
Try to run it. See if you can figure out why it fails. Hint there are 2 
syntax errors.

At python.org there are links to several tutorials which will show you 
how to repeat operations.

To repeat things in Python we can use a loop. What Python statements are 
used for loops?


-- 
Bob Gailer
Chapel Hill NC
919-636-4239


More information about the Tutor mailing list