PY-7

Stop at the First Marker

  • Easy
  • Loops and Sequences
  • Python

Task

Write stop_at_marker(values, marker). Read values from left to right and stop at the first value equal to marker.

Return a three-item tuple:

(consumed, marker_position, found)
  • consumed is a list containing the values before the first marker.
  • marker_position is the marker's index, or None when no marker is present.
  • found is True when a marker is present and False otherwise.

If the marker is absent, consumed must contain every input value. Do not change the input list.

Example

The value after "STOP" is not part of the consumed prefix.

Your implementation

Edit solution.py and keep this function name and signature:

Use a left-to-right loop so the stopping decision remains visible. Return the required tuple; do not print it or ask for input.