Match vs Exact for I/O Tests

Hi everyone,

I use I/O tests a lot for my introductory programming courses and I’m finding that regardless of whether I use match or exact there will always be something about the I/O tests confusing my students.

A lot of my projects have this format:

  1. Prompt the user for some information with an instruction
  2. The user enters the information into the console
  3. The program does something with that information and prints some sort of message

For example, the student might see something like this:

What is your name? Carl
Hi, Carl!

If I create an I/O test using exact, here’s what it would look like:

Input (standard in)
Carl

Expected output
What is your name? Hi, Carl!

The confusing part is that the output looks different than what students see in the console.

If I create an I/O test using match, here’s what it would look like:

Input (standard in)
Carl

Expected output
Hi, Carl!

There are a few confusing parts about this:

  • The word “match” falsely implies an exact match and most students will miss the hover text that clarifies this.
  • When the test fails, the diff shows the prompt struck out in red, falsely suggesting it should be removed.
  • There are going to be false positives since the prompt isn’t checked at all and there could be multiple outputs. For example, if there are three tests for Carl, Sue, and Jeff, the following program would pass all these tests:
print("Hi, Carl!", "Hi, Sue!", "Hi, Jeff!")

This could be solved using regex, however students will be able to see the regex, which is not beginner-friendly and misleading (many of them would think that their program needs to print the literal regex symbols).

What would be really nice is to have an ends with and starts with with option for I/O tests. If I were able to use ends with with the example above, the test would look the same as with match, but it wouldn’t give nearly as many false positives. It would be even better it if were possible to merge ends with and starts with so that the prompt gets checked too.

Input (standard in)
Carl

Expected output starts with
What is your name?

Expected output ends with
Hi, Carl!

Anyway, I was wondering whether anyone is having similar issues and has any suggestions for how to use I/O tests more effectively.

1 Like

Hi @MissStrong thanks for your question.

There was a recent topic about (I think) exactly what you are talking about here:

The last few posts include a video from Replit Support explaining the difference between the two. Hope this helps.

Hi Ian,

I watched the video of Shane clarifying how match works, but it didn’t really address the issue I’m having. My issue is that neither exact nor match are well suited for the use case I described. My suggestion is to create new modes that are designed under the assumption that input() has a string as an argument and the ones I think would be great would be ends with, starts with, and a combination of the two.