Building a cipher - step 40: remove parentheses around space requirement
Describe the Issue
I would suggest we remove the parenthesis from the requirements.
Change:
At the beginning of your loop body, print the result of comparing
charwith a space (' '). Use the equality operator==for that.
To:
At the beginning of your loop body, print the result of comparing
charwith a space' 'using the equality operator==.
I never understood why we sometimes put code inside parenthesis like this. It inevitably results in some people copying it verbatim.
Related issue: #55878
Affected Page
https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-40
Your code
Expected behavior
Avoid confusing syntax when writing code requirments.
Screenshots
No response
System
- Device: [e.g. iPhone 6, Laptop]
- OS: [e.g. iOS 14, Windows 10, Ubuntu 20.04]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]
Additional context
No response
Step 36 also has similar parenthesis https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-36
And elsewhere... https://github.com/freeCodeCamp/freeCodeCamp/blob/21c20c2606d89c08d42db08c2dbd3637b4599d41/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/660d90b0ec1ef7da914c5e65.md?plain=1#L12 https://github.com/freeCodeCamp/freeCodeCamp/blob/21c20c2606d89c08d42db08c2dbd3637b4599d41/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.md?plain=1#L45 https://github.com/freeCodeCamp/freeCodeCamp/blob/21c20c2606d89c08d42db08c2dbd3637b4599d41/curriculum/challenges/english/07-scientific-computing-with-python/learn-recursion-by-solving-the-tower-of-hanoi-puzzle/64de773f81facd14653f49c8.md?plain=1#L14
And other bulk cases... https://github.com/search?q=repo%3AfreeCodeCamp%2FfreeCodeCamp+%2F%5C%28%60%5B%5E%29%5D*%60%5C%29%2F+path%3A%2F%5Ecurriculum%5C%2Fchallenges%5C%2Fenglish%5C%2F%2F&type=code&p=1
Parentheses are used in many cases to enclose additional information and I believe most people understand that.
I would rather change the regex test to use AST-based helpers instead of changing the description. In this way parenthesis would be ignored.
I'm specifically talking about code blocks inside parentheses.
In my experience, the parentheses cause confusion and often gets copied along with the code inside them. I would also consider their use to be inconsistent with how we use code blocks elsewhere in the curriculum.
As a general rule, I have no issue with allowing all valid code to pass. But the requirements should be as clear as possible nevertheless. The fact that we can ignore the parentheses when testing the code in no way changes this.
This has been done in other parts of the curriculum although not consistently. And it would be difficult to change all the occurrences. But I understand your point.
Personally, I don't like the idea of removing the parentheses without changing anything else. It may cause less confusion but it doesn't seem correct to structure the sentence in that way without punctuation. And yes, I know that this is done at the end of that very same sentence. What about using commas?
At the beginning of your loop body, print the result of comparing
charwith a space,' ', using the equality operator,==.
I think using commas would be good. I really don't want to see us modify the tests to help campers blindly copy-paste the ()
I don't mind the punctuation. I usually try not to put any right next to the code blocks if I can help it. Again, it's just to avoid campers copying the punctuation. But I'm fine with what you suggested for the requirements.
Just to clarify, I suggested to modify the tests because the original plan was to avoid the use of regex tests. But when the cipher project has been developed, the AST-based helpers were not ready yet. So we can decide to remove the parentheses, and keep the test as is, or change the test, too. The two things are not strictly related.