Solved

Stage 2 — split("-") breaks LIFE-SUPPORT-4

AmeliaRunsOP edited

I get three parts instead of two.

3

Comments 4

Log in to join the discussion.

Log in Create account
  1. SamPrice Solutionreplies: 2

    Use rsplit with a max split of 1. It splits from the right, only once, so everything before the last dash stays together.

    8
    1. AmeliaRunsOPreplies: 1

      rsplit! Didn't know it existed.

      0
      1. TomBecker

        Same trick for file extensions: "archive.tar.gz".rsplit(".", 1).

        1
    2. BellaRossi

      split also has maxsplit, but it works from the left. For "last separator" cases, rsplit is the tool.

      4