There is three tasks that i wish to achieve in my python script, please guide me test.gh (6.9 KB)
#1 Replace integer by index in the list i had created
e.g. index 0 and -2 to 1
#2 Cull integer by index
#3 Shift the list by one unit
There is three tasks that i wish to achieve in my python script, please guide me test.gh (6.9 KB)
#1 Replace integer by index in the list i had created
e.g. index 0 and -2 to 1
#2 Cull integer by index
#3 Shift the list by one unit
@piac Hey Mate, can u guide me on how to select, replace items in my script?
Hi @jia.yeap,
# example list
list1 = [20, 10, 5, 7.5, 12]
# replace item by index
list1[3] = 8 # [20, 10, 5, 8, 12]
# delete by index
del list1[2] # [20, 10, 8, 12]
# shift list by 1:
list2 = list1[1:] # [10, 8, 12]
# or delete the first
del list1[0]
But your ghpython input hints need to be set to “List Access” in order for this to work.
Great input. This works if your list is if you set yr hint. The issue I am encountering is I had performed mathematical equations inside the script and I need to remove first value and last in ‘a’