Learn Interfaces by Building an Equation Solver - Step 57

Tell us what’s happening:

I’ve seen two other posts about this step, but both are closed and unfortunately, I still don’t get it. I would really appreciate some guidance or direction here.

Step 57

Add another case for when the length of results is 2. This time, assign result_list a list containing two strings with the format x1 = <root1> and x2 = <root2>. Again, make the solution display both positive and negative signs.

match len(results):
        case 0:
            result_list = ['No real roots']
        case 1:
            result_list = [f'x = {results[0]:+}']
        case 2:
            result_list = [f'x1 = {results[0]:+} x2 = {results[1]:+}']


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

Learn Interfaces by Building an Equation Solver - Step 57

does your list contain two strings?

I was thinking about these 2 strings as well and tried this:

case 2:
            result_list = [f'x1 = {results[0]:+}' f'x2 = {results[1]:+}']

But it didn’t work. I also tried adding a + between them to concatenate the strings, even though I didn’t see a good reason for doing that.

Okay, I get it now. I hadn’t separated them properly. Sorry about that! I was trying to figure it out for a long time and couldn’t understand what went wrong because I was sure the code was correct.