Sunday 15 August 2010

Issue with loop "for if else" python -



Issue with loop "for if else" python -

i have problem in next code:

for n in range(0,i)+range(i+1,len(xy_pos)): # excludes i==n if distance(xy_temp,i,n)<sigma: xy_temp[i]=xy_pos[i] # before move break else: xy_pos[i]=xy_temp[i] # move accepted accepted_moves+=1 number.append(number(r)) # overlap status

this part of code codition create or not move particle located in xy_temp[i]. tried construction easier , seemed work, not here. don't have error message, can see in results part after else never executed when should be. think of explanation, warlmy welcome

i'm new in python, hope it's not silly question, after hours looking in net , myself find solution, inquire here.

i tried break @ same level of identation "if", , doesn't seems alter anything.

thank you

you have indent else part.currently script treating part of loop.

for n in range(0,i)+range(i+1,len(xy_pos)): # excludes i==n if distance(xy_temp,i,n)<sigma: xy_temp[i]=xy_pos[i] # before move break else: xy_pos[i]=xy_temp[i] # move accepted accepted_moves+=1 number.append(number(r)) # overlap status

python loops if-statement for-loop

No comments:

Post a Comment