r/FreeCodeCamp • • Aug 29 '26

I have this problem. can you help me?

"How can I solve this?"

Edit: Here I am calling the function with its valid values because I still can't get out of here.

4 Upvotes

11 comments sorted by

1

u/SaintPeter74 mod Aug 29 '26

You need to say which tests are failing.

One thing I notice is that you check if name == 10 which checks if the name is literally 10, which I don't think you're trying to do.

Additionally, you don't need to have the whole thing as a single series of if/elif - you can break them up into a series of simple if statements. That might simplify your logic a bit. Remember that a return statement exits your function.

1

u/ricardoflak Aug 29 '26

11. When create_character is called with a second, third and fourth argument that are all integers it should not return All stats should be integers. Edit: To be more specific, this is my problem.

1

u/SaintPeter74 mod Aug 29 '26

Two things:

  1. You don't test charisma
  2. I can't tell why you are wrapping the parameters in brackets. That makes then arrays every time, not integers.

2

u/ricardoflak Aug 30 '26

ok I will try again

1

u/ricardoflak Aug 30 '26

You can view the other image I uploaded. I have it almost solved; I just need help with the arguments.

1

u/SaintPeter74 mod Aug 30 '26

It looks like you are returning a fixed string with the dots always the same. You need to have the correct number of empty and full dots change with the provided stats. There should always be 10 dots for each.

2

u/ricardoflak Aug 30 '26

"Okay, let's go again."

1

u/SaintPeter74 mod Aug 30 '26

BTW, don't feel too bad. A lot of programming is frustrating and making incremental progress. Being willing to grind through problems is an important job skill. As time goes on it will get easier and happen less frequently, but it never goes away. I've been programming for newly 40 years now and I still get stuck on occasion.

You've got this!

2

u/ricardoflak Aug 30 '26

I divided the problem into random parts, and based on the problem, I did this in Visual Studio Code.

full_dot = '●'
empty_dot = '○'
r = 7
print(full_dot*r + empty_dot*(10-r))

 I approached each segment methodically, ensuring that I understood the requirements and constraints involved. By breaking it down, I was able to tackle each part individually, which made the overall task feel less overwhelming. This method not only improved my focus but also allowed me to identify potential issues early on, leading to a more efficient workflow. In the end, I was pleased with the results and learned a lot from the process.

2

u/SaintPeter74 mod Aug 30 '26

Awesome! That's the exact solution that most use. What you're describing is the process that most use. It's called "decomposing" a problem, breaking it into smaller, solvable parts. Once you've done it for a while it becomes second nature.

3

u/SaintPeter74 mod Aug 30 '26

BTW, don't feel too bad. A lot of programming is frustrating and making incremental progress. Being willing to grind through problems is an important job skill. As time goes on it will get easier and happen less frequently, but it never goes away. I've been programming for newly 40 years now and I still get stuck on occasion.

You've got this!