How to pass a list as an argument in python -


i new python , coding in c++ 2 years. want pass list argument in function display stuff inside in different lines (actually want make own function display stuff)

myvar = [1, 4, 5, 3, 7, 4, 9, 5, 10]  def displaylist(paramlist):     tempindex = 0     in paramlist:         print paramlist[tempindex]         tempindex += 1  displaylist(myvar) 

this wrote , getting this:

1 4 5 3 7 4 9 5 10 

this not expected output. have done wrong.

note: new language.

edit: apologize inconvenience showed exact output wanted, didn't notice because of negligence. please flag question gets deleted

this looks expected output me. note bit more pythony way write code might be

myvar = [1,4,5,3,7,4,9,5,10]  def displaylist(paramlist):     p in paramlist:         print p  displaylist(myvar) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -