Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCWP(Beta) - Learn Classes and Objects by Building a Sudoku Solver - Step 73: Accepting wrong solution #54886

Closed
andrebdinis opened this issue May 20, 2024 · 1 comment · Fixed by #54909
Assignees
Labels
new python course scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: PR in works Work in Progress (WIP) Issues. type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc.

Comments

@andrebdinis
Copy link
Contributor

Describe the Issue

The step asks for a list comprehension, but the following code is accepted as a solution (with parenthesis):
row_str = (str(i) for i in row)

Affected Page

https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-classes-and-objects-by-building-a-sudoku-solver/step-73

Your code

def __str__(self):
        board_str = ''
        for row in self.board:
            row_str = (str(i) for i in row)

Expected behavior

I believe the step must only accept the list comprehension with square brackets []:
row_str = [str(i) for i in row]

Screenshots

No response

System

  • Device: Laptop
  • OS: Windows 11
  • Browser: Brave
  • Version: 1.64.116

Additional context

No response

@andrebdinis andrebdinis added scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and fix. type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc. labels May 20, 2024
@Dario-DC
Copy link
Contributor

Dario-DC commented May 21, 2024

Thank you for reporting this issue. I don't think this is a huge problem, since the code works well with a generator expression too. However, since the instructions are asking for a list comprehension, it makes sense to fix the test.

The helpers do not discriminate between the various comprehension types, so I'd import the ast module and check if the value of the row_str variable is an instance of ast.ListComp. This additional check should take place within this test.

@Dario-DC Dario-DC added help wanted Open for all. You do not need permission to work on these. and removed status: waiting triage This issue needs help from moderators and users to reproduce and confirm its validity and fix. labels May 21, 2024
@ilenia-magoni ilenia-magoni self-assigned this May 21, 2024
@jdwilkin4 jdwilkin4 added status: PR in works Work in Progress (WIP) Issues. and removed help wanted Open for all. You do not need permission to work on these. labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new python course scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: PR in works Work in Progress (WIP) Issues. type: bug Issues that need priority attention. Platform, Curriculum tests (if broken completely), etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants