Build an RPG Character - Build an RPG Character

Tell us what’s happening:

The output in the terminal is correct but the instruction number 10, 12 and 14 is accepting. Is my solution for the if statements not correct?

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name,strength, intelligence, charisma):
    total_stats = strength + intelligence + charisma
    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 and intelligence and charisma), int):
        return "All stats should be integers"
    elif (strength and intelligence and charisma) < 1:
        return "All stats should be no less than 1"
    elif (strength and intelligence and charisma) > 4:
        return "All stats should be no more than 4"
    elif total_stats != 7:
        return "The character should start with 7 points"
    else:
        strength_stats = (full_dot * strength) + (empty_dot * (10 - strength))
        intelligence_stats = (full_dot * intelligence) + (empty_dot * (10 - intelligence))
        charisma_stats = (full_dot * charisma) + (empty_dot * (10 - charisma))
        character_info = f"{name}\nSTR {strength_stats}\nINT {intelligence_stats}\nCHA {charisma_stats}"
        return character_info
        

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/149.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/lab-rpg-character/67d83df6f82eda3868dd2a84.md

Welcome to the forum @Biswas_Rai_Coder,

Does it make sense to do this before you have validated to make sure all of the stats are integers?

Your isinstance() syntax is incorrect. Please review this theory lecture about how to use that:

Understanding Variables and Data Types - How Do the type() and isinstance() Functions Work? | Learn | freeCodeCamp.org

Happy coding

total_stats = strength + intelligence + charisma

I understand now its okey to move this above the elif statement
elif total_stats != 7 ?

elif not isinstance((strength and intelligence and charisma), int)

changed this to

elif not isinstance(strength, int) or not isinstance(inelligence, int) or not isinstance(charisma, int)

Still not working?

please post all your updated code

There are two ways you can format your code to make it easier to read and test:

  1. After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)

  1. Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.

To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor:

total_stats = strength + intelligence + charisma

I understand now. Is it okey to move this above the elif statement
elif total_stats != 7

elif not isinstance((strength and intelligence and charisma), int)

changed this to

elif not isinstance(strength, int) or not isinstance(inelligence, int) or not isinstance(charisma, int)

Still not working?

Please post your updated code formatted as in the above post by ILM so we can help you further.

please post all your code, it is difficult to do anu evaluation from a single line of code

You misspelled intelligence.

OMG A simple mistake silly me.
Thank you i got it.

I see its for the whole code. I got it will do so if I stumble upon any problems in the future.
Thank you