Answers for "python how to split a list"

24

split string python

file='/home/folder/subfolder/my_file.txt'
file_name=file.split('/')[-1].split('.')[0]
Posted by: Guest on April-01-2020
4

python split list

string = 'this is a python string'
wordList = string.split(' ')
Posted by: Guest on March-26-2020
0

python split list

string = "this is a string" 		# Creates the string
splited_string = string.split(" ")	# Splits the string by spaces
print(splited_string) 				# Prints the list to the console
# Output: ['this', 'is', 'a', 'string']
Posted by: Guest on March-29-2021

Code answers related to "python how to split a list"

Python Answers by Framework

Browse Popular Code Answers by Language