Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I’m not able to complete steps 18 and 19. Feeling lost about what to do. Could anyone help?

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, cha):

    points = empty_dot.replace(empty_dot, full_dot)

    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'
    
    if not isinstance(strength, int):
        return 'All stats should be integers'
    if not isinstance(intelligence, int):
        return 'All stats should be integers'
    if not isinstance(cha, int):
        return 'All stats should be integers'
    if strength < 1:
        return 'All stats should be no less than 1'
    if intelligence < 1:
        return 'All stats should be no less than 1'
    if cha < 1:
        return 'All stats should be no less than 1'
    if strength > 4:
        return 'All stats should be no more than 4'
    if intelligence > 4:
        return 'All stats should be no more than 4'
    if cha > 4:
        return 'All stats should be no more than 4'
    if strength + intelligence + cha == 7:
        return
    else:
        return 'The character should start with 7 points'
    if full_dot:
        if strength + 1:
            points =+ 1
            return
        if intelligence + 1:
            points =+ 1
            return
        if cha + 1:
            points =+ 1
            return

    return f'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'

create_character('ren', 4, 2, 1)
print(f'ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○')

Your browser information:

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

Challenge Information:

Build an RPG Character - Build an RPG Character

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-rpg-character/67d83df6f82eda3868dd2a84.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @guilhermesbarb,

Will your code ever get past this point?

Also, you are hard coding the return value based on what is expected in a specific function call.

What if the function call is create_character("Flash",3,4,1)?

Happy coding

I think I’ve fixed it, but I still have no idea how to proceed with the 18 and 19 steps.

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, cha):

    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'
    
    if not (isinstance(strength, int) or  isinstance(intelligence, int) or  isinstance(char, int)):
        return 'All stats should be integers'
    if (strength or intelligence or cha) < 1:
        return 'All stats should be no less than 1'
    if (strength or intelligence or cha) > 4:
        return 'All stats should be no more than 4'
    if strength + intelligence + cha != 7:
	    return 'The character should start with 7 points'

Hi @guilhermesbarb

To help you debug add the following print call.

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

Happy coding

first, make sure you understand what should happen, what should be the output based on any input

Just tackle it one line at a time based on the instructions given to build the return string:

If all values pass the verification, the function should return a string with four lines:

  • the first line should contain the character name
  • lines 2-4 should start with the stat abbreviation, STR, INT or CHA (in this order), then a space, and then a number of full dots () equal to the value of the stat, and a number of empty dots () to reach 10. Example: if the value of strength is 3 there must be 3 full dots followed by 7 empty dots. The dots are given in the editor.

You will need to use the global variables to build the dynamic dots — either full or empty – based on the specific stat value.

I think I gotta make the full_dot increase as the number of str, int or cha increases too, but I’m lost.

I think I should use the replace() to make it works, but how do I change it with the users input like in the create_character('ren', 4, 2, 1)?

What are you replacing?

for each point the user gives to any of the three aspects it should replace an empty dot by a full_dot. I think I got this logic, I just don’t know how to connect it with the theoretical input.

why would you need to replace anything? you need to create a string, you are not starting from an existing string