Build an RPG Character

Needing help with understanding what I am doing wrong here.
I have a few errors that I am getting in the console that I don’t know how to fix.

  1. 5. The create_character function should not say that the character is too long when it's not longer than 10 characters.
    
  2. create_character('ren', 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
    
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
    if not isinstance(name, str):
        return 'The character name should be a string'
    if name == '':
        return 'The character should have a name'
    if len(name) > 10:
        return 'The character name is too long'
    if ' ' in name :
        return 'The character name should not contain spaces'

    stats = [strength, intelligence, charisma]
    if not all(isinstance(stat, int) for stat in stats):
        return 'All stats should be integers'

    if not all(stat >= 1 for stat in stats):
        return 'All stats should be no less than 1'

    if not all(stat <= 4 for stat in stats):
        return 'All stats should be no more than 4'

    if sum(stats) != 7:
        return 'The character should start with 7 points'

    stat_names = ["STR", "INT", "CHA"]
    lines = [name]  # first line is the character name
    for stat_name, value in zip(stat_names, stats):
        # full dots = stat value, empty dots = remaining to 10
        line = f"{stat_name} {'●'*value}{'○'*(10-value)}"
        lines.append(line)

    return(create_character('ren', 4, 2, 1))

Also when I throw a print on the end of the script. I get NONE.

full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
    if not isinstance(name, str):
        return 'The character name should be a string'
    if name == '':
        return 'The character should have a name'
    if len(name) > 10:
        return 'The character name is too long'
    if ' ' in name :
        return 'The character name should not contain spaces'

    stats = [strength, intelligence, charisma]
    if not all(isinstance(stat, int) for stat in stats):
        return 'All stats should be integers'

    if not all(stat >= 1 for stat in stats):
        return 'All stats should be no less than 1'

    if not all(stat <= 4 for stat in stats):
        return 'All stats should be no more than 4'

    if sum(stats) != 7:
        return 'The character should start with 7 points'

    stat_names = ["STR", "INT", "CHA"]
    lines = [name]  # first line is the character name
    for stat_name, value in zip(stat_names, stats):
        # full dots = stat value, empty dots = remaining to 10
        line = f"{stat_name} {'●'*value}{'○'*(10-value)}"
        lines.append(line)

    #return(create_character('ren', 4, 2, 1))
print(create_character("name", 3, 3, 1))

With the print at the end added. I was able to remove the first error I was getting.

But still not understanding how to get the return to work.

  1. create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.

Welcome to the forum @maddenny

What does your function return when the stats are valid?

Happy coding

where is the return?

The return I had commented out at the end of the def.

When I remove the comment. I do not get anything to show in the console.

But I get the same errors.

full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
    if not isinstance(name, str):
        return 'The character name should be a string'
    if name == '':
        return 'The character should have a name'
    if len(name) > 10:
        return 'The character name is too long'
    if ' ' in name :
        return 'The character name should not contain spaces'

    stats = [strength, intelligence, charisma]
    if not all(isinstance(stat, int) for stat in stats):
        return 'All stats should be integers'

    if not all(stat >= 1 for stat in stats):
        return 'All stats should be no less than 1'

    if not all(stat <= 4 for stat in stats):
        return 'All stats should be no more than 4'

    if sum(stats) != 7:
        return 'The character should start with 7 points'

    stat_names = ["STR", "INT", "CHA"]
    lines = [name]  # first line is the character name
    for stat_name, value in zip(stat_names, stats):
        # full dots = stat value, empty dots = remaining to 10
        line = f"{stat_name}{'●'*value}{'○'*(10-value)}"
        lines.append(line)

    return(create_character('ren', 4, 2, 1))
// running tests
5. The create_character function should not say that the character is too long when it's not longer than 10 characters.
11. create_character('ren', 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
12. When create_character is called with valid values it should output the character stats as required.
// tests completed

don’t return the function inside itself, you need to return what the output should be

So, when the instructions are saying. “Here’s the string that should be returned by create_character('ren', 4, 2, 1):” It doesn’t mean to actually use the return as that?

Nope. If your function returns a call to itself, how will it ever return anything?

You need to call the function, outside the function, and print the result.

def function():
    code

print(function())

it means that when you call the function with those arguments that is the output that should be obtained

you should not write a function call inside the function

Okay, thank you.

Now would I need it to be a return or a print?

As the return will error out on every line.

But the print will give me a None. Then the message. “11. create_character(‘ren’, 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.”

When the tests say 'should return, you must return the expected value when calling your function with the specific input.