Python input list of strings | Example code

  • by

Use split() function on input string to get input list of strings in Python. Where the split function splits a string into a list of words.

Example take input list of strings in Python

Simple example code accepts the list of strings from a user in the format of a string separated by space.

input_string = input("Enter name separated by space: ")

# Split string into words
lst = input_string.split(" ")

print(lst)

Output:

Python input list of strings

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

Note: IDE: PyCharm 2021.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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.