-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
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
fix: test catch if function is empty #54597
fix: test catch if function is empty #54597
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code still passes if variables are present outside:
import secrets
import string
# Define the possible characters for the password
letters = string.ascii_letters
digits = string.digits
symbols = string.punctuation
# Combine all characters
all_characters = letters + digits + symbols
def generate_password():
# Define the possible characters for the password
letters = string.ascii_letters
digits = string.digits
symbols = string.punctuation
# Combine all characters
all_characters = letters + digits + symbols
Here is the hint and test to fix this:
The four variable declarations shouldn't exist outside the function.
```js
({
test: () => assert.isFalse(runPython(`
_Node(_code).find_variable('letters').is_equivalent('letters = string.ascii_letters') and \\
_Node(_code).find_variable('digits').is_equivalent('digits = string.digits') and \\
_Node(_code).find_variable('symbols').is_equivalent('symbols = string.punctuation') and \\
_Node(_code).find_variable('all_characters').is_equivalent('all_characters = letters + digits + symbols')
`))
})
```
Yes, I am checking that the new function is defined correctly, which was the issue, not if the are extra pieces of code @zairahira also that test wouldn't work if you want to check that all the variables are not present, it needs to be with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 👍️
Checklist:
main
branch of freeCodeCamp.Closes #54596