735 B
735 B
title | tags | aliases | ||||||
---|---|---|---|---|---|---|---|---|
input() |
|
|
[!note] Concept
Theinput()
function waits for the user to type text and pressENTER
, then returns it as a string.[!example] Example
myName = input()
If the user types
Al
, the result is equivalent to:myName = 'Al'
[!important] Best Practices
- Always assume
input()
returns a string — cast withint()
,float()
, etc. if needed.- Only use
input()
in Python 3. In Python 2, useraw_input()
instead.[!info] Related Notes
typeConversions
functions
pythonSyntaxOverview