0

Is it possible to split() string at " "? I have tried

x=str(input("Enter string to split: ")) #Input: one "two three"
xsplit=str.split()
print(xsplit[1])

but it returns "two" but I want it to show "two three". How to do it?

cpm pipes
  • 13
  • 2

1 Answers1

0

This will let you split on the space as well as gather everything after the split.

x=str(input("Enter string to split: ")) #Input: one "two three"
xsplit = x.split(' ')[1:]
xjoin = ' '.join(xsplit)
print(xjoin)

Once you have split into a list you can rejoin the list into a single string with .join(xsplit)

ArchAngelPwn
  • 2,891
  • 1
  • 4
  • 17