Skip to content

Latest commit

 

History

History
40 lines (23 loc) · 821 Bytes

input.md

File metadata and controls

40 lines (23 loc) · 821 Bytes

INPUT

What is input?

Input is used to read data from user.

How to take input?

There are two functions in Python that you can use to read data from the user: raw_input() and input()

For python 2.x:
input() is used to read integers.
raw_input() is used to read text(strings) from the user.

For python 3.x:
input() is used to read strings.
To read strings, it can be typecasted using int(input())

Multiple inputs can be taken in one line using split()

You can store the results from them into a variable.

Syntax

x = input()
y = raw_input()
a,b,c = input().split()

Examples

num=input("Enter a number: ")

name=raw_input("Enter your name: ")

You can check out more examples here.

For more information on Input:

https://www.pythonforbeginners.com/input/