Skip to content

How to get string input in Python 3 | Example code

  • by

Use input() function to get string input in Python 3. Whatever user will enter as input, the input function converts it into a string.

input(prompt)

Example get string input in Python 3

Simple example code taking string input from the user.

How to get string input in Python 3

Another Example

You can also take input from the user with a message.

name = input("Enter your name: ")

# Output
print("Hello", name)

Output:

Enter your name: John
Hello John

Do comment if you have any doubts and suggestions on this Python input topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading