0

When I input this:

def tablesUsed():
    "Return which multiplication tables to use"
    tablesUsed = [int(x) for x in input("Please choose which multiplication tables you   wish\nto practice, then type them like this: 2 5 10.\n").split()]

python skips over the function to the next line. What is going on?

3
  • 1
    Seems you're just defining it, to make it run you need to call it. Commented Feb 23, 2013 at 11:46
  • Volatility answered you, But instead of input() use raw_input() Commented Feb 23, 2013 at 11:49
  • @GrijeshChauhan the OP is probably using Python 3 (although you really can't tell) Commented Feb 23, 2013 at 11:50

1 Answer 1

5

You need to call it.

tablesUsed()

You also might want to actually return the list.

def tablesUsed():
    return [int(x) for x in input("Please choose which multiplication tables you   wish\nto practice, then type them like this: 2 5 10.\n").split()]

Otherwise you can't access the list you made in the function, making it useless.

Also, if you're using Python 2, input() evaluates the input as Python code, and you're more than likely going to get an error. Use raw_input() to return a string. In Python 3 raw_input() was removed and replaced by input()

Sign up to request clarification or add additional context in comments.

Comments

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.