Python Forum
Fill as list (with conditions).
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fill as list (with conditions).
#6
there are number of problems in your code.
1. in your code, i is the item in the list positions (line 11). At the same time, in the following code you treat it as index. I would assume it's not what you want. So you check that positions[i-1] == 0 (that is positions[-1]==0) and want to check that A[i] > B[i] > C[i] > D[i] or that A[i] < B[i] < C[i] < D[i] in order to append -1. however A[0] == B[0] == C[0] == D[0] == 1 and you don't add anything. so it exits the loop because there are no more values to iterate over
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

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