- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
What is difference between raw_input() and input() functions in Python?
The function raw_input() presents a prompt to the user (the optional arg of raw_input([arg])), gets input from the user and returns the data input by the user in a string. For example,
name = raw_input("What isyour name? ") print "Hello, %s." %name
This differs from input() in that the latter tries to interpret the input given by the user; it is usually best to avoid input() and to stick with raw_input() and custom parsing/conversion code. In Python 3, raw_input() was renamed to input() and can be directly used. For example,
name = input("What is your name? ") print("Hello, %s." %name)
- Related Articles
- How do I check if raw input is integer in Python 3?
- What is the difference between Python functions datetime.now() and datetime.today()?
- What is the difference between dir(), globals() and locals() functions in Python?
- Explain unformatted input and output functions in C language
- Difference Between range() and xrange() Functions in Python?
- What is the difference between CONCAT() and CONCAT_WS() functions?
- What is difference in getattr() and setattr() functions in Python?
- What does input() function do in python?
- Taking input in Python
- What is the difference between jQuery.map() and jQuery.grep() Functions in jQuery?
- What is the difference between jQuery.map() and jQuery.each() Functions in jQuery?
- What is the difference between ajaxSend() and ajaxStart() functions in jQuery?
- What is the difference between ajaxStop() and ajaxComplete() functions in jQuery?