What does find() return if nothing is found? OLOllieGrantOP 13 Sep, 11:01 Not needed for the stage, but I'm curious.
BEBellaRossi13 Sep, 12:35replies: 2It 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.
Comments 4
Join the discussion CommentAlready have an account? Log in
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 being a valid index is sneaky.
The "Search the log" + "Filter the log" combo is a nice way to learn this.
Or use
infirst, like stage 1 does. Then you know find() will succeed.