Build an RPG Character - Build an RPG Character

Tell us what’s happening:

im not able to pass any tests, could you help me figure out my mistake

Your code so far

full_dot = '●'
empty_dot = '○'
def create_character(name,strength,intelligence,charishma):
    if not isinstance(name,str):
        return'The character name should be a string.'
    elif name=='':
        return 'The character should have a name.'
    elif name>10:
        return 'The character name is too long'
    elif ' ' in name:
        return 'The character name should not contain spaces.'


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

Hi @tanishaabatra ,

Please double check your validation messages. Do they match exactly to the instructions? Look closely.

Happy coding!

Tell us what’s happening:

i am not able to pass test 18 and 19, could you help me find my errors?

Your code so far

full_dot = '●'
empty_dot='○'
def create_character(name,strength,intelligence,charisma):
    stats = (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'
    elif 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'
    elif 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'
    elif 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'
    elif sum(stats) !=7:
        return 'The character should start with 7 points'
    else:
        empty_dots = "○○○○○○○○○○"
        full_dots = "●" * strength + empty_dots[strength:]
        int_dots = "●" * intelligence + empty_dots[intelligence:]
        cha_dots = "●" * charisma + empty_dots[charisma:]
        print(f"{name}\n STR {full_dots}\n INT {int_dots}\n CHA {cha_dots}")
        return f"{name}\n STR{full_dots}\n INT{int_dots}\n CHA{cha_dots}"
    
print(repr(create_character('ren', 4, 2, 1)))





    
    
    
    


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

Hi @tanishaabatra,

Take a close look at your return and how everything is aligned. Add a second call that is just a print that invokes create_character so that you can better see the alignment on screen and follow the instructions carefully with spacing, paying close attention to where the steps want the output to be.

Think of the steps in these projects as a very picky boss who wants the display their way or the highway lol

Happy Coding!

Tell us what’s happening:

not able to complete test 18 and 19, please give the correct code

Your code so far

full_dot = '●'
empty_dot='○'
def create_character(name,strength,intelligence,charishma):
    stats = (strength,intelligence,charishma)
    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'
    elif not isinstance(strength,int):
        return 'All stats should be integers'
    elif not isinstance(intelligence,int):
        return 'All stats should be integers'
    elif not isinstance(charishma,int):
        return 'All stats should be integers'
    elif strength<1:
        return 'All stats should be no less than 1'
    elif intelligence<1:
        return 'All stats should be no less than 1'
    elif charishma<1:
        return 'All stats should be no less than 1'
    elif strength>4:
        return 'All stats should be no more than 4'
    elif intelligence>4:
        return 'All stats should be no more than 4'
    elif charishma>4:
        return 'All stats should be no more than 4'
    elif sum(stats) !=7:
        return 'The character should start with 7 points'
    else:
        return 
        'name' 
        'STR'(full_dot*strength)+((10-strength)*empty_dot)
        'INT'(full_dot*intelligence)+((10-intelligence)*empty_dot)
        'CHA'(full_dot*charisma)+((10-charisma)*empty_dot)
    
print(create_character('ren', 4, 2, 1))

    
    
    
    


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

1 Like

I can’t give you the right code but i would be happy to help you find the correct answer if you are willing to work through it

1 Like

what is the current output in the terminal when you try and check the code so far? are there any errors?

the output that im receiving is None. i dont know how to fix it, could you help me?

Tell us what’s happening:

i am not able to get the required output. what am i doing wrong?

Your code so far

full_dot = '●'
empty_dot='○'
def create_character(name,strength,intelligence,charisma):
    stats = (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'
    elif 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'
    elif 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'
    elif 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'
    elif sum(stats) !=7:
        return 'The character should start with 7 points'
    else:
        str_line = '\nSTR' + full_dot * strength + empty_dot * (10 - strength)
        int_line = '\nINT' + full_dot * intelligence + empty_dot * (10 - intelligence)
        cha_line = '\nCHA' + full_dot * charisma + empty_dot * (10- charisma)
  
        return f'{name}\n{str_line}\n{int_line}\n{cha_line}'


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





    
    
    
    


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

Hi @tanishaabatra ,

Your function stops processing when it hits return, so it is not seeing the strings after that. You see None in the console because your function does not return anything.

Happy coding!

I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.

To see what you function returns in the console, build your function call like this:

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

Now you should be able to see the difference between what your code returns and what is expected.

Tell us what’s happening:

im not able to pass the last two tests. help me find what is wrong in my code.

Your code so far

full_dot = '●'
empty_dot='○'
def create_character(name,strength,intelligence,charisma):
    stats = (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'
    elif 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'
    elif 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'
    elif 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'
    elif sum(stats) !=7:
        return 'The character should start with 7 points'
    else:
        str_line = '\nSTR' + full_dot * strength + empty_dot * (10 - strength)
        int_line = '\nINT' + full_dot * intelligence + empty_dot * (10 - intelligence)
        cha_line = '\nCHA' + full_dot * charisma + empty_dot * (10- charisma)
  
        return f'{name}\n{str_line}\n{int_line}\n{cha_line}'


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





    
    
    
    


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build an RPG Character - Build an RPG Character

Please do not create duplicate topics for the same challenge/project question(s). If you need more help then respond back to the original topic you created with your follow up questions and/or your updated code and question.

Your duplicated topics have been unlisted.

Thank you.

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

this is my updated code, im not able to pass the last two tests, please help me figure out whats wrong.

Please post your updated code using the method shown in a previous post.

full_dot = ‘●’

empty_dot=‘○’

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

stats = (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’

elif 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’

elif 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’

elif 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’

elif sum(stats) !=7:

return ‘The character should start with 7 points’

else:

    str_line = '\\nSTR' + full_dot \* strength + empty_dot \* (10 - strength)

    int_line = '\\nINT' + full_dot \* intelligence + empty_dot \* (10 - intelligence)

    cha_line = '\\nCHA' + full_dot \* charisma + empty_dot \* (10- charisma)

return f’{name}{str_line}{int_line}{cha_line}’

print(create_character(‘ren’,4, 2, 1))

We cannot test your code when it is not formatted. The code in your post is showing no indentation…very important in Python.

Is there something you did not understand in the code formatting instructions that we can help with?

Also, you are now calling your function with a print(), so you should be seeing what your code produces in the console.

How does that differ from what the tests expect? Another way to call your function so you can see the newline characters is to call it like this:

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

Once you see the differences, you should be able to fix your code to return the expected string.

this is my updated code, still not able to pass thw last two tests.

full_dot = ‘●’

empty_dot=‘○’

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

stats = (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’

elif 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’

elif 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’

elif 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’

elif sum(stats) !=7:

return ‘The character should start with 7 points’

else:

    str_line = '\\nSTR' + full_dot \* strength + empty_dot \* (10 - strength)

    int_line = '\\nINT' + full_dot \* intelligence + empty_dot \* (10 - intelligence)

    cha_line = '\\nCHA' + full_dot \* charisma + empty_dot \* (10- charisma)

return f’{name}{str_line}{int_line}{cha_line}’

print(repr(create_character(‘ren’, 4, 2, 1)))