Solved

Order of strip and lower — does it matter?

AmeliaRunsOP

Should it be typed.strip().lower() or typed.lower().strip()?

3

Comments 4

Join the discussion

Already have an account? Log in

  1. FreyaL Solutionreplies: 1

    Here it doesn't matter, both give the same result. Method chaining just runs left to right, each method returning a new string.

    2
    1. TomBecker

      In stage 3 the order does matter a bit: replace the underscores/dashes before you compare, of course.

      5
      1. LucasVD

        casefold() is a stronger lower() for international text (e.g. German ß). For commands, lower() is fine.

        3