> Anyone have any ideas? l = "wisconsin_state.txt" l.split(".")[0].split("_")[-1] Explanation: ------------------- the split(".")[0] part takes everything before the "." the split("_")[-1] part selects in the last element in the list of substrings which are separated by "_"