Answers for "line.split() python"

3

python split lines

>>> text = """Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia,
molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum
numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium
optio, eaque rerum! Provident similique accusantium nemo autem."""

# the str.splitlines() method is basically just str.split("n").
>>> text.splitlines()
[
	'Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia,',
	'molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum',
	'numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium',
	'optio, eaque rerum! Provident similique accusantium nemo autem.'
]
Posted by: Guest on March-01-2021
23

split string python

string = 'James Smith Bond'
x = string.split(' ') #Splits every ' ' (space) in the string to a list
# x = ['James','Smith','Bond']
print('The name is',x[-1],',',x[0],x[-1])
Posted by: Guest on September-08-2020
0

python split

text = 'geeks for geeks'
  
# Splits at space
print(text.split())
Posted by: Guest on October-26-2021

Python Answers by Framework

Browse Popular Code Answers by Language