Tell us what’s happening:
Can’t see exactly what’s wrong in my code. Looks to me that its returning the correct values.
Your code so far
# User Editable Region
details = equation.analyze()
match details:
case {'slope': slope, 'intercept': intercept}:
details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']
case {'x': x, 'y': y, 'min_max': min_max, 'concavity': concavity}:
details_list = [f'concavity = {concavity}', f'min_max = ({x:.3f},{y:.3f})']
for detail in details_list:
output_string += f'{detail}\n'
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15
Challenge Information:
Learn Interfaces by Building an Equation Solver - Step 64
I changed the following, still can’t get it write. It says “solver isn’t returning the right output”.
case {'x': x, 'y': y, 'min_max': min_max, 'concavity': concavity}:
details_list = [f'concavity = {concavity}', f'{min_max} = ({x:.3f},{y:.3f})']
```
Solved it. Simply by changing the code a little bit. Output still remains the same. Can someone explain why this is more correct than the above?
case {'x': x, 'y': y, 'min_max': min_max, 'concavity': concavity}:
xy = f' ({x:.3f},{y:.3f})'
details_list = [f'concavity = {concavity}', f'{min_max} = {xy}']
The only thing I can see is maybe the spacing on your first try. I’m thinking if you had a space after the comma between your x and y variables it might pass. I was really struggling to get it formatted correctly. I even tried your code but couldn’t get it to pass. Turned out my problem was I was centering the output in the “for” loop. They didn’t wan’t it that neat apparently. Seems like these tests are very particular on spacing and such. My code looks like your first example only with a space where I mentioned.
*edit: Just finished all the lessons and it turns out your last example is closer to what they want to make final formatting work. Mine passed but they changed it to look more like your second example in the next lesson.
1 Like