Build an RPG Character - Build an RPG Character

Tell us what’s happening:

i have done everything up to copy and pasting code from google but nothing working i am not able the pass the lab

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(character_name, strength, intelligence, charisma):
    stats = [strength, intelligence, charisma]
    
    # --- Character Name Validations ---
    # 1. Must be a string
    if not isinstance(character_name, str):
        return "The character name should be a string."
    
    # 2. Must not be empty
    if character_name == "":
        return "The character should have a name."
    
    # 3. Must not be longer than 10 characters
    if len(character_name) > 10:
        return "The character name is too long."
    
    # 4. Must not contain spaces
    if " " in character_name:
        return "The character name should not contain spaces."
    
    # --- Stats Validations ---
    # 5. All stats must be integers (exclude booleans explicitly)
    if not all(isinstance(s, int) and not isinstance(s, bool) for s in stats):
        return "All stats should be integers."
    
    # 6. All stats must be >= 1
    if any(s < 1 for s in stats):
        return "All stats should be no less than 1."
    
    # 7. All stats must be <= 4
    if any(s > 4 for s in stats):
        return "All stats should be no more than 4."
    
    # 8. Sum of stats must be exactly 7
    if sum(stats) != 7:
        return "The character should start with 7 points."
    
    # --- Format Output ---
    # Calculate dots: (full * value) + (empty * remaining)
    str_dots = full_dot * strength + empty_dot * (10 - strength)
    int_dots = full_dot * intelligence + empty_dot * (10 - intelligence)
    cha_dots = full_dot * charisma + empty_dot * (10 - charisma)
    
    # Return formatted string with \n newlines and NO colons
    return f"{character_name}\nSTR {str_dots}\nINT {int_dots}\nCHA {cha_dots}"   

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 @shadab.ahmad0028,

Please check the messages you are returning. Should those contain punctuation? Compare to the instructions as they must match exactly.

Happy coding

yup i have checked the punctuation but its not working.

By “not working” do you mean you changed the messages and it still doesn’t work? If so, please post your updated code, formatted as follows:

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:

As a code it works but as per the commands given to me they are failing for some reason.

So you haven’t made any changes to the code you originally posted? Yes or No.

i have by excuting the code

full_dot = ‘●’

empty_dot = ‘○’

def create_character(character_name, strength, intelligence, charisma):

stats = \[strength, intelligence, charisma\]



\# --- Character Name Validations ---

\# 1. Must be a string

if not isinstance(character_name, str):

    return "The character name should be a string."



\# 2. Must not be empty

elif character_name == " ":

    return "The character should have a name."



\# 3. Must not be longer than 10 characters

elif len(character_name) > 10:

    return "The character name is too long."



\# 4. Must not contain spaces

elif " " in character_name:

    return "The character name should not contain spaces."



\# --- Stats Validations ---

\# 5. All stats must be integers (exclude booleans explicitly)

elif not all(isinstance(s, int) and not isinstance(s, bool) for s in stats):

    return "All stats should be integers."



\# 6. All stats must be >= 1

elif any(s < 1 for s in stats):

    return "All stats should be no less than 1."



\# 7. All stats must be <= 4

elif any(s > 4 for s in stats):

    return "All stats should be no more than 4."



\# 8. Sum of stats must be exactly 7

elif sum(stats) != 7:

    return "The character should start with 7 points."



\# --- Format Output ---

\# Calculate dots: (full \* value) + (empty \* remaining)

str_dots = full_dot \* strength + empty_dot \* (10 - strength)

int_dots = full_dot \* intelligence + empty_dot \* (10 - intelligence)

cha_dots = full_dot \* charisma + empty_dot \* (10 - charisma)



\# Return formatted string with \\n newlines and NO colons

return f"{character_name}\\nSTR {str_dots}\\nINT {int_dots}\\nCHA {cha_dots}"   

# Example Usage:

result = create_character(“ren”, 4, 2, 1)

print(result)

You have not changed any of the return messages. They still do not match what is in the instructions!

This is the message the instructions ask you to return:

The character name should be a string

You have a full stop in yours, but there is no full stop in the messages provided in the instructions.

oh i see, so sorry for such a time waste of your and thank u.