Solved Nine elifs → one dict. So satisfying. BEBellaRossiOP 1 Oct, 07:54 edited Just finished stage 1. Replacing that chain with a dict feels great.
SASamPrice1 Oct, 20:00 Solutionreplies: 1Tip 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.
MAMateoG2 Oct, 09:34replies: 1Stage 2 with whole newtons — use round() or :.0f, check which one matches.
Comments 5
Join the discussion CommentAlready have an account? Log in
It's one of the best refactors there is. Data in a table, logic in one line.
Tip for anyone stuck:
GRAVITY_M_S2.get(body)returns None for unknown bodies, so checkif gravity is None:to print the no-data line and keep the output identical.Yes, that's how I kept the no-data message.
Stage 2 with whole newtons — use
round()or:.0f, check which one matches.:.0fworked for me.