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?
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?
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)