Use an input() function with split() function to take list as input in Python. Using a split() function will split an input string by space.
Example take the list as input in Python
Simple example code input() function to accept the list elements from a user in the format of a string separated by space. And The split() method splits a string into a list.
input_string = input('Enter separated by space: ') user_list = input_string.split() # print list print('list: ', user_list)
Do comment if you have any doubts or suggestions on this Python List input code.
Note: IDE: PyCharm 2021.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.