Build an RPG Character - Build an RPG Character

Tell us what’s happening:

i dont know what is the broplem i but the same stats the he told me to but in the user story

Your code so far


def create_character(name, strength, intelligence, charisma):
    full_dot = '●'
    empty_dot = '○'
    if not isinstance(name, str):
        return 'The character name should be a string'
    elif name == '':
        return 'The character should have a name'
    elif len(name) > 10:
        return 'The character name is too long'
    elif ' ' in name :
        return 'The character name should not contain spaces'
    elif not isinstance(strength, int):
        return 'All stats should be integers'
    elif not isinstance(intelligence, int):
        return 'All stats should be integers'
    elif not isinstance(charisma, int):
        return 'All stats should be integers'
    elif strength < 1 or intelligence <1 or charisma < 1:
        return 'All stats should be no less than 1'
    elif strength > 4 or intelligence > 4 or charisma > 4:
        return 'All stats should be no more than 4'
    elif strength + intelligence + charisma != 7:
        return 'The character should start with 7 points'
    
    else :
        return 'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'
print(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/147.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

Hi @hassan12,

You are hard coding your return based on specific expected values.

That is not solving this problem in the general case. Imagine if you were given different input values. Would your code be able to solve those problems?

Here’s an example: print(create_character('giraffe', 3, 1, 3))

To find out more about what hard-coding is or about why it is not suitable for solving coding questions, please read this post: Hard-coding For Beginners

Let us know if you have a question about how to make your code more flexible.

Happy coding!

yes can you tell me how to make it more flexiable

Build your return string using the parameters passed to the function. That way what you return string will always reflect the arguments passed to the function call.

Do I have to use the full_dot and empty_dot

hay i did what you said with some help from other people code and i can but any name and numbers it will print it on the terminal but it still tell me that (create_character(‘ren’, 4, 2, 1)) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○

Please post your updated code.


When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Tell us what’s happening:

This is my updated code. If I change it to create_character(‘hassan’, 3 ,1 ,3), it will print the stats and the name at the terminal

Your code so far


def create_character(name, STR, INT, CHA):
    full_dot = '●'
    empty_dot = '○'
    if not isinstance(name, str):
        return 'The character name should be a string'
    elif name == '':
        return 'The character should have a name'
    elif len(name) > 10:
        return 'The character name is too long'
    elif ' ' in name :
        return 'The character name should not contain spaces'
    elif not isinstance(STR, int):
        return 'All stats should be integers'
    elif not isinstance(INT, int):
        return 'All stats should be integers'
    elif not isinstance(CHA, int):
        return 'All stats should be integers'
    elif STR < 1 or INT <1 or CHA < 1:
        return 'All stats should be no less than 1'
    elif STR > 4 or INT > 4 or CHA > 4:
        return 'All stats should be no more than 4'
    elif STR + INT + CHA != 7:
        return 'The character should start with 7 points'
        
    else :
        return f'{name} \nSTR{full_dot*STR}{empty_dot*(10-STR)}\nINT{full_dot*INT}{empty_dot*(10-INT)}\nCHA{full_dot*CHA}{empty_dot*(10-CHA)}'
print(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/147.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.

ok actully i fell that I’m the dumbest person because I just have to add space and thank you for your help and sorry for all this q

You are not dumb. You are learning. And that’s pretty smart!