Python range problem(Help!)

Hello, everyone, I am an architect and very beginner in programming, and this for the architectural task that we faced and trying to solve it and its hard for me because i am not very familiar with python , I tried really since while to fix a problem in python for Dynamo revit but I couldn’t, and I am very appreciated for your help,
what I am trying to do is, I have two inputs, first input contains three-level points list ,and 2 level number list .
if number is 1 output element at index 0
if number is 2 output element at index 0 twice
if number is 3 output element at index 0 twice and 1
if number is 4 output element at index 0 twice and 2 twice
if number is 5 output element at index 0 twice and 2 twice and three and so on.

i would like to ask how its possible to get the elements in the range of the number in list two,
here is the error and the code that I tried to do, very appreciated for help from you.

I’m not sure what you are trying to do.

I’m not sure that you are using range correctly. range(start, stop, step) provides a list of numbers from start until stop, incrementing by step.

range(start, stop, step) = [start, start+step, start+2*step, ..., start+i*step] where start+i*step < stop but start+(i+1)*step >= stop

For example,
range(0, 6, 2) = [0, 2, 4]

Your use of range is counting by twos, which doesn’t make sense for what you seem to be saying.

For the future, its much easier if you copy and paste your code into your post.

Hello Bob, thanks for your replay, maybe I can explain it in another way, what I wanted to do is for example if the number is 4 in (0 List) in IN[1] I wanted to have an output 4 elements or indexes from (0 List) in IN[0] without being out of the length of (0 List) this is the first thing, the second thing 4 output element at index 0 two times and 2 two times that was even case numbers, for odd numbers like 3 for example output should be 3 elements element at (index 0) twice and (index 1) and(index 2) two times , sorry if I couldn’t explain it in a correct way , and yes that would be easier i will upload the code .

import sys
import clr
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
List = IN[0]
Number = IN[1]

output = []
# Place your code below this line
for n in Number : 
	for l in List: 
		temp = [] 
		if n % 2 == 0:
			for i in range(0,n,2):
		elif n % 2 != 0:
			j = 0
			for i in range(0,n-1,2):
				j = i
# Assign your output to the OUT variable.
OUT = output

Could you provide me with some example inputs and outputs? What you’re trying to do still doesn’t make sense to me.

Hello Bob , i did a small diagram to explain .

and so on
Input (5) output are points at index 00 22 3
Input (6) output are points at index 00 22 44

This is a bizzare coding challenge, but I think I have a handle on what you want.

I think your issue is in the logic of your loop. It’s more complicated than you need and that complexity is making it hard to debug.

I’d start with pen and paper (I’m serious!) and write down a checklist that you would follow if you were to do this by hand. Something like

For i=0…n

  1. print(which index would work?)

okay Bob , i am gonna try it and check it again , the code i wrote worked for some cases , but sometimes for higher input in Input two it didn’t , because the loop stay at level two and cant go through indexes in level one