Answers for "split string into two parts python"

1

how to split a string into two strings python

# Python3 code to demonstrate working of
# Splitting string into equal halves
# Using string slicing

# initializing string
test_str = "GeeksforGeeks"

# printing original string
print("The original string is : " + test_str)

# Using string slicing
# Splitting string into equal halves
res_first, res_second = test_str[:len(test_str)//2],
						test_str[len(test_str)//2:]

# printing result
print("The first part of string : " + res_first)
print("The second part of string : " + res_second)
Posted by: Guest on April-06-2021
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

Code answers related to "split string into two parts python"

Python Answers by Framework

Browse Popular Code Answers by Language