Input or raw_input?

5

Can anyone tell me the difference between input and raw_input in Python and what is the proper way to use both?

    
asked by anonymous 06.04.2016 / 18:14

2 answers

4

The difference is that raw_input() does not exist in Python 3.x , while input() exists. In fact the old raw_input() has been renamed to input() and the old input() no longer exists (although it can be simulated using eval(input()).

As far as I'm researching, in Python 2.x , the command input() "evaluates" the context in which the call was made. Here's an example:

>>> x = input()
"hello"
>>> y = input()
x + " world"
>>> y
'hello world'
    
06.04.2016 / 18:17
0

The raw_input () returns the value typed as string, and the input () returns the value as integer Note: input () only accepts numbers

    
13.04.2016 / 18:02