Vincent Wan wrote:
So
You were doing fine up to here...
for x in list:
do_something_with_an_element(list[x])
and python keeps track of x for you.
Now you are back into your original mistake! It should be
for x in list:
do_something_with_an_element(x)
The variable in a for loop receives the ac
PROBLEM SOLVED THANK YOU DANNY AND ALAN
To recap:
My program main loop called two functions one that changed a list and
one that printed the list. Turns out that print function was bad.
I didn't understand how clever pythons for statement is. I wrote:
def write_list(list_to_write, file_name):
> def write_list(list_to_write, file_name):
> "Writes elements of a list, seperated by spaces, to a file"
> for each in list_to_write:
> file_name.write(str(list_to_write[each]) + ' ')
This is the problem.(I think)
You are taking each element of the list then using
it(either 0
On Thu, 6 Jan 2005, Vincent Wan wrote:
> On Jan 6, 2005, at 12:59 PM, Danny Yoo wrote:
> > Can you show us a snippet of the file output? I'm not immediately
> > seeing anything particular with your debugging output statements:
>
> > Like the computer, I don't yet understand what the problem is.
Dear Danny,
On Jan 6, 2005, at 12:59 PM, Danny Yoo wrote:
Can you show us a snippet of the file output? I'm not immediately
seeing
anything particular with your debugging output statements:
Like the computer, I don't yet understand what the problem is. *grin*
If you can point us at the outpu
On Thu, 6 Jan 2005, Vincent Wan wrote:
> I wrote a program to repeatedly:
> a: print a list of integers eg 0 0 0 0 0 0 0 0 0 0
> b: change each integer in the list to 1 with a .05% chance
>
> I run the program and over itterations more 1's appear as they should.
>
> However, the chan
Dear All,
I am trying to learn python and an having a problem.
I wrote a program to repeatedly:
a: print a list of integers eg 0 0 0 0 0 0 0 0 0 0
b: change each integer in the list to 1 with a .05% chance
I run the program and over itterations more 1's appear as they should.
Howeve