freeCodeCamp / freeCodeCamp

freeCodeCamp.org's open-source codebase and curriculum. Learn to code for free.
https://contribute.freecodecamp.org
BSD 3-Clause "New" or "Revised" License
404.57k stars 37.91k forks source link

[Learn Python List Comprehension by Building a Case Converter Program - Step 5] f'string interpolation fails lesson but concatenation passes #56836

Open TracyChacon opened 1 day ago

TracyChacon commented 1 day ago

Describe the Issue

[Learn Python List Comprehension by Building a Case Converter Program - Step 5] f'string interpolation fails lesson but concatenation passes

Affected Page

https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-list-comprehension-by-building-a-case-converter-program/step-5

Your code

if char.isupper():

            converted_character = f'_{char.lower()}'     # fails test
            converted_character = '_' + char.lower()    # passes test  

# Sorry, your code does not pass. Keep trying.

# You should assign the modified character to a variable named converted_character.![Image](https://github.com/user-attachments/assets/40669693-8e7b-4dc4-b2cf-3a4e499286d0)

Expected behavior

f'string should pass test

Screenshots

No response

System

Additional context

No response

ilenia-magoni commented 17 hours ago

Right now the tests use a strict regex: https://github.com/freeCodeCamp/freeCodeCamp/blob/df4c4e3fd2419ff81ad903a9263599faedd27b6b/curriculum/challenges/english/07-scientific-computing-with-python/learn-list-comprehension-by-building-a-case-converter-program/657efa642593c5746acc5c81.md?plain=1#L18-L28

The test should be changed to use AST based helpers and accept both the concatenation and the f-string. Documentation on AST helpers can be found here: https://opensource.freecodecamp.org/curriculum-helpers/python.html#ast-based-helpers

The second test should also be updated to use AST based helpers: https://github.com/freeCodeCamp/freeCodeCamp/blob/df4c4e3fd2419ff81ad903a9263599faedd27b6b/curriculum/challenges/english/07-scientific-computing-with-python/learn-list-comprehension-by-building-a-case-converter-program/657efa642593c5746acc5c81.md?plain=1#L32-L40

Please make sure you read our guidelines for contributing, we prioritize contributors following the instructions in our guides. Join us in our chat room or our forum if you need help contributing; our moderators will guide you through this.

Sometimes we may get more than one pull request. We typically accept the most quality contribution followed by the one that is made first.

Happy contributing.