Solved

Nine elifs → one dict. So satisfying.

BellaRossiOP edited

Just finished stage 1. Replacing that chain with a dict feels great.

11

Comments 5

Join the discussion

Already have an account? Log in

  1. CharlieH

    It's one of the best refactors there is. Data in a table, logic in one line.

    0
    1. SamPrice Solutionreplies: 1

      Tip for anyone stuck: GRAVITY_M_S2.get(body) returns None for unknown bodies, so check if gravity is None: to print the no-data line and keep the output identical.

      6
      1. MateoGreplies: 1

        Stage 2 with whole newtons — use round() or :.0f, check which one matches.

        5