I am a complete newbie to python and attempting to pass an array as an argument to a python function that declares a list/array as the parameter.
I am sure I am declaring it wrong,
here goes:
def dosomething(listparam):
#do something here
dosomething(listargument)
Clearly this is not working, what am I doing wrong?
Thanks
What you have is on the right track.
Produces the output:
A couple of things to note given your comment above: unlike in C-family languages, you often don’t need to bother with tracking the index while iterating over a list, unless the index itself is important. If you really do need the index, though, you can use
enumerate(list)to getindex,elementpairs, rather than doing thex in range(len(thelist))dance.