-1

I was writing a program in Python for a command-line application.

When it comes to the time to split the given input into separate strings for reading the input and processing it, I hit a snag.

I found out the cause was due to an extra space when splitting the given input using string.split("\"").

Then I proceeded to use a for loop to eliminate the spaces at the end of the string using method string.strip().

But alas, I found that the string was unchanged.

Am I doing anything wrong, or does the interpreter have some problem?

command = ["cd ", "C:\\Users"]
for i in command:
    # Trying to remove the space off the end of command[0], i.e, "cd "
    i = i.strip()
print(command)  # Still outputs ["cd ", "C:\\Users"]
mkrieger1
  • 14,486
  • 4
  • 43
  • 54
who
  • 11
  • 4

0 Answers0