Python Forum
Fill as list (with conditions).
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fill as list (with conditions).
#4
You are modifying the list on the go during the for loop. This is not a good idea. I admit that I am unable to see what is going on looking at the script.

If you want to play with the index you can use enumerate.
for index, element in enumerate([4,3,2,1,0]):
    print(index + 1, element)
Output:
1 4 2 3 3 2 4 1 5 0
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
Fill as list (with conditions). - by EmericCrue - May-11-2018, 01:00 PM
RE: Fill as list (with conditions). - by wavic - May-11-2018, 01:22 PM
RE: Fill as list (with conditions). - by EmericCrue - May-11-2018, 01:41 PM
RE: Fill as list (with conditions). - by wavic - May-11-2018, 02:03 PM
RE: Fill as list (with conditions). - by EmericCrue - May-11-2018, 03:13 PM
RE: Fill as list (with conditions). - by buran - May-11-2018, 03:18 PM
RE: Fill as list (with conditions). - by nilamo - May-11-2018, 03:21 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020