mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-19 21:09:51 +08:00
fix(curriculum): test fails if it's not list comprehension (#54909)
This commit is contained in:
parent
15d0281c95
commit
c2ad373b90
@ -20,7 +20,12 @@ You should declare a variable `row_str`.
|
||||
You should assign a list comprehension that iterates over `row` to the `row_str` variable.
|
||||
|
||||
```js
|
||||
({ test: () => assert(runPython(`_Node(_code).find_class("Board").find_function("__str__").find_for_loops()[0].find_bodies()[0].find_variable("row_str").find_comp_iters()[0].is_equivalent("row")`)) })
|
||||
({ test: () => (runPython(`
|
||||
import ast
|
||||
var = _Node(_code).find_class("Board").find_function("__str__").find_for_loops()[0].find_bodies()[0].find_variable("row_str")
|
||||
assert var.find_comp_iters()[0].is_equivalent("row"), "You should iterate over row"
|
||||
assert isinstance(var.tree.value, ast.ListComp), "It's not a list comprehension"
|
||||
`)) })
|
||||
```
|
||||
|
||||
The list comprehension assigned to the `row_str` variable should use `i` as iteration variable.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user