Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I cannot understand how to pass test 7… rather troubled on this one

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'

    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) and not isinstance (intelligence, int) and not isinstance (charisma, int):
        return 'All stats should be integers'

Your browser information:

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

Challenge Information:

Build an RPG Character - Build an RPG Character

Is this validation test actually checking for a space inside the name?

So you only want to return a validation error if ALL of the stats are not integers?

sorry im confused at what you are saying…?

what are you confused about? which part do you need clairifcations for?

My code satisfies test 6 so I don’t see the problem with the first issue he mentioned. And the other, I just don’t understand at all.

you are passing test 6 because you are returning the right string when it should be returned, but the code could still be wrong, if you are also returning the value when it should not be returned

so, check it, print(create_character('ren', 4, 2, 1)), what is your function returning?

nothing? I feel prepared to just give up but don’t really want to

how have you added this line in your code? you should see the output of your function in the terminal

you need to add this below your function, outside of it, with no indentation

Sorry, yes put it outside of the function and it returns in the terminal ‘The character name should not contain spaces’

so do you see that the string is being returned when it should not being returned?

do you understand now why dhess asked you this?

But it asks you to return this?

only when there is a space in the name

try print('' in 'ren'), do you expect it to be True or False?

Yeah it is True, just struggling to understand what code it should be

if you want to check if there is a space, is '' a space? (or maybe an empty string?)

empty string, think I understand a bit better now. So I just needed to add a space in that?

an empty string and a space are different strings, so if you want to check for a space you need to use a space yes

Does that look correct now?

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):
    
    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 you check with print(create_character('ren', 4, 2, 1)), do you still see 'The character name should not contain spaces' in the terminal?

Nope, it says “none”

did you maybe remove the code that was below return 'The character name should not contain spaces'?