In this tutorial, we will discuss What’s The Difference Between `raw_input()` and `input()` in Python 3, As raw input() was used in python 2 which was used for reading the string input. which is not there in the case of python 3.
In python 3 we simply use input() to get input in both the ways like strings as well as non string input, So we can say the input() function acts as input() as well as raw input() in python3 which make it more advance
In python 2 when we have to take the input we use raw input when we have to take string input so to understand the example given below.
name = raw_ input("What is your name? ") print("Hello, " + name + "!")
It was used when we have to take input in python 2 but in Python3 the scenario is being changed we can simply use input() to get all the types of data. As nowpython2 is not being in use so every one uses python3 as it have more features
name = input("What is your name? ") print("Hello, " + name + "!")
And evaluate the input we use the eval() function in python3 to evaluate the input given below
expression = input("Enter a mathematical expression: ") result = eval( expression) print("The result is " + str(result))
There are so many other features that is being updated in python3 as compared to python2 to know more about such upgrades or changes that are being suggested in python 3 and which were not there in python 2 visit: Python2 vs Python3.
To learn more about python programming- related problems and concepts tutorials visit: Python Tutorial – How to Use Global Variables in a Function | Python Programs Examples.
To learn more about different other programming languages and solve the problems faced during solving all the problems and getting the concepts to get the programming done visit beta python for programming languages Solutions. and keep learning and growing