Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:15:35+00:00 2026-06-09T13:15:35+00:00

I am a complete newbie to python and attempting to pass an array as

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:15:36+00:00Added an answer on June 9, 2026 at 1:15 pm

    What you have is on the right track.

    def dosomething( thelist ):
        for element in thelist:
            print element
    
    dosomething( ['1','2','3'] )
    alist = ['red','green','blue']
    dosomething( alist )  
    

    Produces the output:

    1
    2
    3
    red
    green
    blue
    

    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 get index,element pairs, rather than doing the x in range(len(thelist)) dance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will begin by saying that I'm a complete newbie as far as AppleScript
I'm a complete newbie in ruby but I can feel that this code can
I'm not new to Python but a complete newbie with regular expressions (on my
I am a complete newbie at Mac. It so happened that now I'm working
I am a Python newbie writing a Python (2.7) script that needs to exec
Complete newbie researching Rails. Can Rails be used with a read-only schema that doesn't
I'm a complete newbie to Git, not really sure what's going on. My buddy
I'll need to preface this with the fact that I am a complete newbie
I am complete newbie in Python and have to modify existing Python script. The
I'm a complete newbie in Haskell. One thing that always bugs me is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.