raw_input confusion


#1

so I'm taking computer science 110 atm and the way we learned to do input is to put eval(input("blah blah blah") and I'm not entirely sure what the difference is with raw_input. I looked it up on the internet and I couldn't find an explanation only that raw input is not used in the current version of python. could someone explain to me (in detail if possible) the difference of these methods or what raw input used to do because i'm very confused


#2

In Python2.x to prompt user for input the command is

raw_input("statement")

In Python3.x to prompt user for input the command is(the command was changed to this)

input("statement")

#3

oh so essential they are just the same thing?


#4

Yes they perform the same task. Just exist in different releases of the language


#5

alright one last question where does eval(input( come into play


#6

eval() interprets a string as code.It lets a python program run python code within itself. try this in the editor you are using

print(eval(input("Enter a mathematical expression")))
#if you put in 2*(4+6) you get ==> 20

def double(number):
    return number*2
    
for i in range(5):
    print (eval("double(i)"))

#7

Did you get it? Were you able to run it
RUN IT HERE


#8

may be a bit late but yes i did get it Thanks