python recursive function

2008-01-11 Thread Tom_chicollegeboy
here is what I have to do: This question involves a game with teddy bears. The game starts when I give you some bears. You then start giving me back some bears, but you must follow these rules (where n is the number of bears that you have): If n is even, then you may give back exactly n/2 bears.

Re: how to iterate through each set

2007-11-03 Thread Tom_chicollegeboy
I figured out problem. here is my code. now it works as it should! Thank you everyone! def speed(): infile = open('speed.in', 'r') line = infile.readline() read = int(line) while '-1' not in line: i = 0 t0 = 0 v = 0 if len(line.split())==1:

Re: how to iterate through each set

2007-11-03 Thread Tom_chicollegeboy
On Nov 4, 12:47 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sat, 03 Nov 2007 21:30:10 -0700, Tom_chicollegeboy > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > It works only for first set. How should I implement another soluti

Re: how to iterate through each set

2007-11-03 Thread Tom_chicollegeboy
On Nov 4, 12:18 am, Cameron Walsh <[EMAIL PROTECTED]> wrote: > Tom_chicollegeboy wrote: > > > > > Here is my code: > > > def speed(): > > infile = open('speed.in', 'r') > > line = infile.readline() > > read =

how to iterate through each set

2007-11-03 Thread Tom_chicollegeboy
I am begginer in learning Python language. My assignment is to iterate through each set and display results. this is text of assignment: Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a workin