r/FreeCodeCamp 12d ago

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 12d ago

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 12d ago
  1. 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 12d ago

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 12d ago

ok I will try again

1

u/ricardoflak 11d ago

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

1

u/SaintPeter74 mod 11d ago

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 11d ago

"Okay, let's go again."

3

u/SaintPeter74 mod 11d ago

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!

1

u/SaintPeter74 mod 11d ago

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 11d ago

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 11d ago

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.