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

learnpython.org > Modules and Packages > Exercise - RUN button flags code equivalent to solution as erroneous #477

Open
RussellJQA opened this issue May 23, 2020 · 0 comments

Comments

@RussellJQA
Copy link

In the learnpython.org tutorial's "Modules and Packages" Exercise, the RUN button flagged my exercise answer code:

find_functions = []
for function in dir(re):
	if "find" in function:
		find_functions.append(function)
	print(sorted(find_functions))

as erroneous. It complained:

Did you define the variable find_members without errors?

Yet, this code is identical (ignoring whitespace) to the solution, except that I named my variable "find_functions" instead of "find_members".

Could the code evaluation be changed to just parse the program output, instead of looking for a specific implementation?

Someone I know showed me his solution to this exercise, and I noticed that it didn't use any variable. He used a list comprehension, with a conditional clause:

print(sorted([x for x in dir(re) if "find" in x]))

I entered that, and it, too, got flagged with:

Did you define the variable find_members without errors?

Yet since list comprehensions haven't yet been discussed in the tutorial, I understand why this wasn't given as the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant