You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
default
[0:-2]substring.[0:-2]for that purpose makes me nervous. If anyone takes that code to apply it in a non-Windows context, they'll certainly change the obviousdir C:tolsor whatever. But they could easily fail to realize that[0:-2]should be changed to[0:-1]. I'd recommend.rstrip()instead, which would work on any platform (unless you want to capture other trailing whitespace), and also makes the reason behind the string alteration clearer.ls /instead ofdir C:.