In this program, we will take a user input as a string and convert that string into a list with the help of the below-given steps.
Convert a string into a list:
Steps to solve the program
- Take a string as input.
- Split the given string using the split function and store it in a variable.
- Print the variable to see the output.
#Input string
string = "i am learning python"
#Splitting the string
list1 = string.split(" ")
#Printing output
print(list1)
Output :
['i', 'am', 'learning', 'python']
Related Articles
Python program to replace the last and the first number of the list with the word.
Python program to check whether the given element is exist in the list or not.
Python program to remove all odd index elements.
Python program to take two lists and return true if then at least one common member.
Python program to convert multiple numbers from a list into a single number.
Python program to convert words of a list into a single string.