Table of contents
1.
Introduction
2.
raw_input Python
2.1.
Syntax
3.
input function Vs. raw_input function
4.
Python 2
4.1.
Code
4.2.
Output
4.3.
Code
4.4.
Output
5.
Python 3
5.1.
Code
5.2.
Output
6.
Frequently Asked Questions
6.1.
Can we use the raw_input function in python 3?
6.2.
How to input multiple times in Python?
6.3.
What are the types of inputs in Python?
6.4.
What are lists in Python?
6.5.
What are functions in Python?
7.
Conclusion
Last Updated: Aug 13, 2025
Easy

raw_input Function in Python

Author Muskan Sharma
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hey Readers!!

While working on Python, you've used the input function and raw_input Python to take the user's desired input.

But have you ever wondered how the raw_input function is different from the input function?

Let's begin to learn more about this!!

raw_input Function in Python

raw_input Python

raw_input is an inbuilt function in python 2, which is used to get the input from the user, and it will take the input exactly typed by the user and pass it back as a string value. 

Syntax

Variable name= raw_input()

Here, 

Variable name: The name of variable you want to use.

raw_input(): The function takes the input and returns the value in an integer.

input function Vs. raw_input function

Both functions are used to take input from the user.

  • In the raw_input function, the data entered by the user is explicitly converted into a string, and it will return the string as the output. 
  • In the input function, if the user input and the type are in integer type or list, it will only take the type as integer or list.
  • The  raw_input function is used in python 2 only, and this function is not supported in python 3.
  • The input function is used in both python 2 and 3.

Let’s look at the examples for more understanding

Python 2

Let’s begin to understand raw_input in python 2 with the help of an examples

Code

ninjas = raw_input("Hey Ninjas!! Enter your name")
print(type(ninjas))
print(ninjas)
You can also try this code with Online Python Compiler
Run Code

Output

Output


In this example, the user entered the string type name, and the raw_input function passed the input as a string.

Code

ninjas = raw_input("Enter your mobile number")
print(ninjas)
print(type(ninjas))
You can also try this code with Online Python Compiler
Run Code

Output

Output

In the above example, the user has input the mobile number, an integer type input, but the raw_input function explicitly converts the input data into a string.

Also Read, Swapcase in Python

Python 3

Now let's look at whether the raw_input works in python 3 or not with the help of an example

Code

ninjas = raw_input("Hey Ninjas!! Have you registered for the course?")
print(ninjas)
You can also try this code with Online Python Compiler
Run Code

Output

Output

In the above example, there is an error because the raw_input function is not supported by Python 3.

Frequently Asked Questions

Can we use the raw_input function in python 3?

No, the raw_input function is not supported in python 3. To take the input from the user, the raw_input has to be replaced by the input function.

How to input multiple times in Python?

To input, multiple times in Python, Use the split() function.

What are the types of inputs in Python?

There are only two types of input in Python: raw_input function and input function.

What are lists in Python?

Lists in Python are used to store multiple values into a single variable.

What are functions in Python?

A function known as a block of code that only executes when it is being called.

Conclusion

This blog has extensively discussed raw_input Python. This article helped enhance your knowledge about the difference between the raw_input function and the input function in Python.

If you want to learn more deeply, check out the excellent content on the Coding Ninjas Website:

Python PowerSwapcase MethodReduce Function in Python , Isupper in pythonFloor Division in PythonPython Square Root

You can also consider our paid courses such as DSA in Python to give your career an edge over others!

For placement preparations, visit interview experiences and interview bundle.

Thank You

Do upvote our blog to help other ninjas grow. Happy Coding!

Live masterclass