What does find() return if nothing is found?

OllieGrantOP

Not needed for the stage, but I'm curious.

5

Comments 4

Join the discussion

Already have an account? Log in

  1. BellaRossireplies: 2

    It returns -1. That's a trap: -1 is a valid slice index (the last character), so slicing with it silently gives nonsense. Always check for -1 first, or use index(), which raises an error instead.

    1
      1. OliviaPy

        The "Search the log" + "Filter the log" combo is a nice way to learn this.

        6
    1. JackStack

      Or use in first, like stage 1 does. Then you know find() will succeed.

      6