If I have a input line such as
userInput = input("Enter stuff: ").split()
which returns a list split by spaces.
How would I go about getting this to keep quoted text as a single item in the list?
eg. If I input hello "where are you?"
I want to get a list with ['hello', 'where are you?']
instead of ['hello', '"where', 'are', 'you?"']
Currently I am using a for loop to add the quoted text back together but I was hoping for a sleeker way.
userInputString = ""
for x in userInput[1:]:
userInputString = userInputString + x + " "
userInputString = userInputString[1:-2] #remove the quotes and the last space