0

How do you limit the input to 6 characters as well as catch if any special characters were inserted?

1 Answer 1

1

Do you mean raw_input() ? (http://docs.python.org/2/library/functions.html#raw_input)

EDITED TO ADD:

Try something like this:

if len(sys.argv) > 1:
    ssid_end = sys.argv[1].lower()
else:
    ssid_end = raw_input("==> ").lower()
Sign up to request clarification or add additional context in comments.

4 Comments

So you're saying you're running python wifi.py [something] and it raises this IndexError ?
I added "userinput = raw_input('--> ')" at the top below both "import" and once I run the program and insert the 6 characters it shows me this error. Otherwise it's fine and I can run the script without raw_input()
Ah of course if you run the script without any parameters you shouldn't try reading sys.argv[1].
WOW ! Hats off dude, love you so much ! It works with your code, thank you, thank you so much !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.