Build an RPG Character - Build an RPG Character

Tell us what’s happening:

I am a bit lost to get the code for the stats right - as far as I got atm . With my code I get the return “All stats should be integers” and I don’t know how to tackle the problem properly. In the forum I saw that other people used code which was not introduced in the course yet (like ‘for’, ‘any’ or ‘all’) or did I overlooked someting? Is this necessary or is it possible to solve the task with the given tools?
Thanks a lot in advance!

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, stre, inte, cha):
    if not isinstance(name, str):
        return "The character name should be a string"
    if name.isspace() == True:
        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"

    int_stats = [stre, inte, cha]
    if not isinstance((stre,inte,cha), int):
        return "All stats should be integers"
    if stre < 1 or inte < 1 or cha < 1: 
        return "All stats should be no less than 1"
    if stre > 4 or inte > 4 or cha > 4: 
        return "All stats should be no more than 4"
    if sum(stre, inte, cha) != 7: 
        return "All sats should start with 7 points"

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0

Challenge Information:

Build an RPG Character - Build an RPG Character

Welcome to the forum @patrick.weissler!

It is not necessary to create a list or use any of the methods you mentioned to solve this challenge. Use what you have learned so far.

Your syntax is incorrect for isinstance(). You can use that method to check multiple types for one variable, but you cannot use it to check a type for multiple variables.

Happy coding!

Thank you for your quick and friendly reply.

So, I changed the code in the line as follows

“if not isinstance(stre, int) and not isinstance(inte, int) and not isinstance(cha, int):”

Now I get “None” as a result, which means the function isn’t giving data back, right? But that is weird, since I am not changing the code fundamentally, am I?

I don’t aks for a solution here, I want to solve it on my own (as far as I can lol). But I don’t have a clue here how to fix this any other way with the given tools.

You just need to build and return the final string asked for in User Story #5. Your code change looks good! Keep going!

Thanks again for your help. In the end, it worked. Let’s see where I’ll be wrong next time to success. :’D