[Tutor] new

Max Noel maxnoel_fr at yahoo.fr
Wed Mar 16 03:07:25 CET 2005


On Mar 16, 2005, at 02:02, Ian Martin wrote:

> Hey I am new at python and i am trying to learn about
> it.  I was wondering if you could tell me how to write
> a range to 100. such as   1+2+3+4+5  ect. without
> writing it out.

	Well, I'm not going to give you the full solution (that'd spoil the 
fun), but the range() function will generate a sequence of integers 
depending on the parameters you pass to it (for example, 
range(start=20, stop=100, step=10) will return [20, 30, 40, 50, 60, 70, 
80, 90]). Then, you could use the sum() function.

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?"



More information about the Tutor mailing list