Reputation: 11
I'm using Python 2.7 and developing an application in both Ubuntu and Windows. On Windows it works fine---no issues. But on Ubuntu it seems to be doing something odd on this bit:
numberoffiles = raw_input('\nHow many files would you like to compare? ')
numberoffiles = int(numberoffiles)
filelist = []
for i in range(numberoffiles):
myfilename = raw_input('\nEnter a file path: ')
filelist.append(myfilename)
print filelist
I'm expecting a list of file names in the format:
['path/to/file1.ext','path/to/file2.ext',...]
But Python is adding double quotes and spaces, so that I get:
["'/path/to/file1.ext' ", "'/path/to/file2.ext' ",...]
If it's a quirk, I can get around it, but I'd like to understand what I'm doing wrong or what exactly is happening here. Any answers would be appreciated.
Upvotes: 1
Views: 146
Reputation: 451
You will need to check your input. If you are giving the input as '/path/filename' then even on windows you will have the double quotes added. Ensure you don't add quotes when you are providing the input.
Upvotes: 1
Reputation: 500357
My money is on the extra quotes (and trailing spaces) being part of the input you are providing to the script.
Upvotes: 0