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.
raw_inputis a very bad thing to do. You should either loop inraw_inputto read as many times as you need, or you should stop usingraw_inputand read from somewhere else that is already in the expected format.