0

I am trying to learn python language. For this I am using Python 3.3.2 Shell. The problem I am facing is this: When I type

    var = input("Enter number here")

It asks me for an input but even if I give an integer value as an input it gives me error

    TypeError: Can't convert 'int' object to str implicitly

I don't face this problem in python 2.7 shell. Can anyone tell why? Thanks in advance

2
  • 3
    I suspect you're typing a few more things than you actually say. Please start a new python shell, and copy/paste the entire thing. Commented Mar 3, 2016 at 14:51
  • 1
    Python 3's input() is equivalent to Python 2's raw_input(), which does not evaluate the input string for you. You have to do it yourself using int() Commented Mar 3, 2016 at 14:57

1 Answer 1

1

well you need to know which type of input you will have, in case of number you should revise your code to the following:

 var = int(input("Enter number here"))
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.