Build an RPG character - Build an RPG Character

Tell us what’s happening:

My code appear’s to work in the terminal, but the tests don’t validate it.

I’m trying to not use loops, although it made the code repetitive.

Your code so far

full_dot = '●'
empty_dot = '○'


def create_character(name, strength, intelligence, charisma):
    
    # Name Validation
    
    if not isinstance(name, str):
        return 'The character name should be a string.'
    if len(name) >= 10:
        return 'The character name is too long.'
    if " " in name:
        return 'The character name should not contain spaces.'
    
    # Stats Validation

    if not isinstance(strength, int):
        return 'All stats should be integers.'
    elif not isinstance(intelligence, int):
        return 'All stats should be integers.'
    elif not isinstance(charisma, int):
        return 'All stats should be integers.'

    if strength < 1:
        return 'All stats should be no less than 1'
    elif intelligence < 1:
        return 'All stats should be no less than 1'
    elif charisma < 1:
        return 'All stats should be no less than 1'
    
    if strength > 4:
        return 'All stats should be no more than 4'
    elif intelligence > 4:
        return 'All stats should be no more than 4'
    elif charisma > 4:
        return 'All stats should be no more than 4'

    if (strength + intelligence + charisma) != 7:
        return 'The character should start with 7 points.' 
    
    return (
        f'{name}' 
        f'\nSTR {full_dot*strength + empty_dot*(10-strength)}' 
        f'\nINT {full_dot*intelligence + empty_dot*(10-intelligence)}'
        f'\nCHR {full_dot*charisma + empty_dot*(10-charisma)}'
    )


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

Challenge Information:

Build an RPG character - Build an RPG Character

Welcome to the forum @passpassjr

For test 2, carefully check the string. You have an extra symbol.

Happy coding

1 Like

Thx mate!

The dot, right?

1 Like