EDIT: Apparently the below question is too specific. Let me rephrase:I'm looking for a way to fit a letter into a list of specified ranges such that, if given the letter S and the ranges A-F, G-M, N-T, U-Z, it would select the third range.ORIGINAL QUESTION:So let's say I have a file: John_Smith.pdfAnd I have a directory hierarchy like so:A/B/C/D/...Z/And inside each of those directories there are subdirectories that further breaks files down by the first two letters rather than the first (the breakdowns are not the same in every folder). In the S/ directory, the subdirectories could look like this:SA-SF/SG-SM/SN-ST/SU-SZ/How can I, using Python, put John_Smith.pdf into the appropriate directory (S/SG-SM/)? It would be preferable for this to be as OS agnostic as possible (e.g. using os.path.join instead of hard coding '/' or '\'. )Thanks!
Move file into apropriate directory based upon first letter of second word, followed by the first two letters of the second word with Python
python;operating systems;sorting;scripting
I found the answer here. Python actually has this functionality built in. For example'A' < 'F' # Returns true because A comes before FThus one can use the functiondef is_in_range(range, letter):    return range[:2] <= letter <=range[3:5]is_in_range('SA-SF','SM')Falseis_in_range('SG-SM','SM')TrueNote: Case will screw this up so .upper() will be needed