Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I’ve tried all I can but I can’t get past problem 18 and 19 even though the code does what is required

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name,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'
    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(charisma,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 charisma < 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 charisma > 4:
        return "All stats should be no more than 4"
    if (strength + intelligence+ charisma) != 7:
        return'The character should start with 7 points'
    stats = (name,strength,intelligence,charisma )
    if not stats == True:
        return name+('\nSTR' + full_dot*strength+empty_dot*(10-strength)) + ( '\nINT' +full_dot*intelligence+empty_dot*(10-intelligence))+ ('\nCHA' +full_dot*charisma+empty_dot*(10-charisma))
    
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/143.0.0.0 Safari/537.36 OPR/127.0.0.0 (Edition ms_store)

Challenge Information:

Build an RPG Character - Build an RPG Character

If I am not mistaken, when it asks for you to your code to return this line

18. create_character('ren', 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.

It means verbatim that line that they specify. currently your code returns this in the terminal

ren
STR●●●●○○○○○○
INT●●○○○○○○○○
CHA●○○○○○○○○○

You can also put this line at the bottom of your code so you can visually see what your code is returning in the terminal

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

P.S. Welcome to the forum, and Happy Coding!

Welcome to the forum @Masondo!

Please test your code like this to compare actual to expected:

print('Actual:   ',repr(create_character('ren', 4, 2, 1))) 
print('Expected: ',repr('ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○'))

Happy coding!

I’m grateful for the help and the warm welcome , The problem was my understanding because for the life of me I also can’t understand what no.19 wants me to do, I put in create_character(‘ren’, 4, 2, 1) which I assume are the correct values but nothing is happening

You won’t be able to see in the console. what your function returns unless you wrap your function call in print().

What did you see in the console when you tried the actual vs expected code above?

The function returns

ren

STR●●●●○○○○○○

INT●●○○○○○○○○

CHA●○○○○○○○○○

When I print() it to the console this is after I’ve modified my code

What does this show in the console?

If you have modified your function code, please post the updated code here for more help.

When I use

print('Actual: ',repr(create_character(‘ren’, 4, 2, 1)))
print('Expected: ',repr(‘ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○’)) it returns

‘ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○’ on the console

Why did you replace this?

With this?

Here, you have hard-coded the value that your specific function call is expecting. That is not solving the problem. What if you called your function like this instead? create_character('giant',3,1,3) Would your code return the correct string?

Also, what’s the purpose of this bit?

The reason was because this is what the program wanted, it actually got me past problem 18. I didn’t want to hard code it but it wouldn’t accept my other piece of code.

The reason I used, stats = (name,strength,intelligence,charisma )

if not stats == True: . was because I thought it was the only way for it to return the results of the code before it