0% found this document useful (0 votes)
8 views

26.Python User Input

Uploaded by

sowndaryas0201
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

26.Python User Input

Uploaded by

sowndaryas0201
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python User Input

Python allows for user input.


That means we are able to ask the user for input.
The method is a bit different in Python 3.6 than Python 2.7.
Python 3.6 uses the input() method.
Python 2.7 uses the raw_input() method.
The following example asks for the username, and when you entered the
username, it gets printed on the screen
Example
Python 3.6
In [3]: username = input("Enter username:")
x = "Username is: "
print( x + username)

Username is: hjkfbglgewhjv

Example
Python 2.7
In [2]: username = raw_input("Enter username:")
print("Username is: " + username)

------------------------------------------------------------------------
---
NameError Traceback (most recent call la
st)
Cell In[2], line 1
----> 1 username = raw_input("Enter username:")
2 print("Username is: " + username)

NameError: name 'raw_input' is not defined

Python stops executing when it comes to the input() function, and continues
when the user has given some input

You might also like