I know this is a very basic question, but I would be happy if you could answer it.
As you can see in the image, I am trying to make a calculation using the value received at IN[0].
However, I am getting the following error and it is not working.
How can I make the calculation work?
Node Name: Python Script
Package: Core.Scripting
Dynamo Version: 2.16.1.2727
Host: Dynamo Revit
Messages: TypeError : can only concatenate list (not “int”) to list [’ File “”, line 8, in \n’].
State: Warning
You have a list with one number in it.
If you take the number out of the list, it will sum just fine, but you cannot add 100 and a list.
Add a for loop, utilize list comprehension, or remove the list structure.
I know this is very generous of me, but can you give us a specific example (script)?
Here is an example I came up with
input_list = IN[0]
if isinstance(input_list, list) and len(input_list) > 0:
R = float(input_list[0])
else:
R = 0.0
S = R + 100.000
OUT = [S]
For loop:
inputList= IN[0]
if not isinstance(inputList, list): sys.exit("The provided input is not a list. Make sure you're feeding in a list to the input or this message will just keep happening.")
results = []
for i in inputList:
r = i+100
results.append(r)
OUT = results
List comprehension:
inputList = IN[0]
if not isinstance(inputList, list): sys.exit("The provided input is not a list. Make sure you're feeding in a list to the input or this message will just keep happening.")
r = [i+100 for i in inputList]
OUT = r
Work with non-list:
input = IN[0]
if isinstance(input, list): sys.exit("The provided input is a list. Make sure you're feeding in a single number to the input or this message will just keep happening.")
r = input+100
OUT = r