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

  • SEARCH
  • Home
  • 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 9164009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:34:42+00:00 2026-06-17T14:34:42+00:00

Beginner with python here. I’ve been doing some online tutorials and can’t seem to

  • 0

Beginner with python here. I’ve been doing some online tutorials and can’t seem to find the solution to this question. What I’d like to do is this:

hostname = raw_input("Type host name here: ")

Then the user inputs as many host names as they like, type done, then what they entered becomes variables for use in the script. So if they typed HOST1, HOST2, HOST3, done then the script would run commands for each entry. Example:

def myhostsbecomevariables(*args):
      arg1, arg2, arg3, etc etc etc = args
      print "arg1: %r, arg2: %r, etc: %r, etc: %r" % (arg1, arg2, etc etc)

myhostsbecomevariables(HOST1, HOST2, HOST3)

If the user types in 3 host names then myhostbecomesvariables uses 3 arguments. If they had typed 5 host names then it would have 5 arguments.

  • 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-17T14:34:44+00:00Added an answer on June 17, 2026 at 2:34 pm

    raw_input returns a single string. You can split that string on a delimiter if you wish:

    hosts = raw_input("enter hosts (separated by a comma):").split(',')
    

    Or split onto 2 lines:

    host_string = raw_input("enter hosts (separated by a comma):")
    hosts = hosts_string.split(',')
    

    And you could pass this to myhostbecomevariables using argument unpacking:

    myhostbecomevariables(*hosts)
    

    where your function could be defined like this:

    def myhostbecomevariables(*hosts):
        for host in hosts:
            print(host)
    

    There really is no need to unpack the hosts into constituent parts here — Since (I assume) you’ll be performing the same action for each host, just do it in a loop.

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

Sidebar

Related Questions

Python beginner here, so I apologize if this question has a simple answer. (I
I'm a beginner in python so this may be too simple question to ask
Python beginner here. I've looked around and found similar questions but can't quite cobble
Right I am a complete beginner here, trying to work through various python tutorials
I came here to ask a simple, very beginner question regarding python. I just
Python beginner here, I have a list of lists and want to refer to
Python beginner here. I have a text file that is sorted into columns: fields
I've got a question related to a beginner Python snippet I've written to introduce
I am beginner in python, and I need to use some thirdparty function which
I'm almost an absolute beginner in Python, but I am asked to manage some

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.