Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Don’t quite understand what the issue actually is-

errors are:

// running tests
9. When create_character is called with a second, third or fourth argument that is higher than 4 it should return All stats should be no more than 4.
10. When create_character is called with a second, third or fourth argument that do not sum to 7 it should return The character should start with 7 points.
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

Your code so far

full_dot = '●'
empty_dot = '○'
def create_character(char_name, stren, intel, rizz):
#char_name
    if not isinstance(char_name, str):
        return "The character name should be a string"
    if char_name == "":
        return "The character should have a name"
    if len(char_name) > 10:
        return "The character name is too long"
    if " " in char_name:
        return "The character name should not contain spaces"
#stats
    if not all(isinstance(v, int) for v in (stren, intel, rizz)):
        return "All stats should be integers"
    if stren or intel or rizz <1:
        return "All stats should be no less than 1"
    if (
        stren or intel or rizz) >4:
        return "All stats should be no more than 4"
    if stren + intel + rizz != 7:
        return "The character should start with 7 points"
#output
    return char_name
    return "\n"
    return "STR" + stren*full_dot + (10-stren)*empty_dot
    return "\n"
    return "INT" + intel*full_dot + (10-intel)*empty_dot
    return "\n"
    return "CHA" + rizz*full_dot + (10-rizz)*empty_dot
create_character("ren", 4, 2, 1)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0

Challenge Information:

Build an RPG Character - Build an RPG Character

this is not checkint that they are all less than 1

the check is
if (stren) or (intel) or (rizz < 1):

or wants full expressions on each side

with this one you have a similar issue, stren or intel or rizz is solved first, so only one value comes out of it, generally stren, so at the end you are only checking stren > 4

did this, but same problem arises:

if (stren) or (intel) or (rizz >4):
        return "All stats should be no more than 4"

that was not the correct syntax to use, that was me showing you that what you wrote was equivalent to that

is stren a full expression that check that stren is higher than 4?

or wants a full expression on each side

1 Like

now just the output remains, probably making some silly error again?

shows:

// running tests
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

code is:

#output
    return char_name + "\n"
    return "STR" + full_dot*(stren) + empty_dot*(10-stren) +"\n"
    return "INT" + full_dot*(intel) + empty_dot*(10-intel) +"\n"
    return "CHA" + full_dot*(rizz) + empty_dot*(10-rizz)
create_character("ren", 4, 2, 1)

full code:

full_dot = '●'
empty_dot = '○'
def create_character(char_name, stren, intel, rizz):
#char_name
    if not isinstance(char_name, str):
        return "The character name should be a string"
    if char_name == "":
        return "The character should have a name"
    if len(char_name) > 10:
        return "The character name is too long"
    if " " in char_name:
        return "The character name should not contain spaces"
#stats
    if not all(isinstance(v, int) for v in (stren, intel, rizz)):
        return "All stats should be integers"
    if (stren<1) or (intel<1) or (rizz <1):
        return "All stats should be no less than 1"
    if (stren>4) or (intel>4) or (rizz >4):
        return "All stats should be no more than 4"
    if (stren + intel + rizz) != 7:
        return "The character should start with 7 points"
#output
    return char_name + "\n"
    return "STR" + full_dot*(stren) + empty_dot*(10-stren) +"\n"
    return "INT" + full_dot*(intel) + empty_dot*(10-intel) +"\n"
    return "CHA" + full_dot*(rizz) + empty_dot*(10-rizz)
create_character("ren", 4, 2, 1)

this is your return, only one return is ever going to execute in a function, so the other return lines below this one are ignored

you need to crate one single string to return

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.