Sorry if this has already been answered, I'm very new to python, I've had a good look around and have found this page here which has helped me a little but i'm still stuck.
I'm trying to get any type of input to work in my script, I've got it working for a single item and a list of items, but i'm finding it hard to get it to work for a list of lists.
I've edited the code as per comments to make a little more sense:
Input = [[1,2,3],[4,5,6],[7,8,9]]
if isinstance(Input, list):
Input = Input
else:
Input = [Input]
listout = []
for x in Input:
listout.append(x+2)
print (listout)
returns: line 12, in listout.append(x+2) TypeError: can only concatenate list (not "int") to list
This works if Input = 1 or Input = [1,2,3,4] for example, but not for the above.
I would like the output to look like the below for a list of lists:
[[3,4,5],[6,7,8],[9,10,11]]
I attempted to make a flat list out of the nested lists first but i'd like to keep the list structure for the output.
Thanks all for reading,
TJ
Inputs instead of using some library for that. Maybe justInput = 1,Input = [1,2,3], etc. and then explain based on these what doesn't work (or what you want).