Build an RPG Character - Build an RPG Character

Tell us what’s happening:

Hi,

I’m passing some tests and failing some but when I call the function with arguments it shows the right results.

Your code so far

full_dot = '●'
empty_dot = '○'

def create_character(name, strength, intelligence, charisma):
    if not isinstance(name, str):
        print('The character name should be a string')
    if not name:
        print('The character should have a name')
    if len(name) >10:
        print('The character name is too long')
    if ' ' in name:
        print('The character name should not contain spaces')

    stats = [strength, intelligence, charisma] 

    for stat in stats:
        if not isinstance(stat, int):
            print('All stats should be integers')
        if stat < 1:
            print('All stats should be no less than 1')
        if stat > 4:
            print('All stats should be no more than 4')
        if sum(stats)!= 7:
            print('The character should start with 7 points')

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

Challenge Information:

Build an RPG Character - Build an RPG Character

what are you seeing in the terminal? can you copy paste it over here?

When I call your create_character function with print I am returning None in the terminal indicating to me that the code is not written properly yet you may still have work to do with it

my terminal is blank. doesn’t show any errors. But when I try changing the arguments to test the conditions I’m getting the right outputs. is there a terminal setting that may be messed up on my end?

how are you calling your create_character function?

If i edit your code and change ‘ren’ to a number (AKA int or integer) in your create_character call I return in the terminal way more than the test is asking for.

you’re right. I changed my code to fix that but still can’t pass tests 2, 4, 6, 8, 10, 12, 14, 16, 18, 19.

full_dot = ‘●’

empty_dot = ‘○’

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

if not isinstance(name, str):

    print('The character name should be a string')

elif not name:

    print('The character should have a name')

elif len(name) >10:

    print('The character name is too long')

elif ' ' in name:

    print('The character name should not contain spaces')



stats = \[strength, intelligence, charisma\] 



for stat in stats:

    if not isinstance(stat, int):

        print('All stats should be integers')

    if stat < 1:

        print('All stats should be no less than 1')

    elif stat > 4:

        print('All stats should be no more than 4')

    elif sum(stats)!= 7:

        print('The character should start with 7 points')

create_character(1, 4, 2, 1)


terminal shows “integer should be a string” but doesn’t pass test2..

I still cant see how you are calling your create_character() function.

scratch that i didnt see the post above that one. Give me one sec.

I use the call :
create_character(1, 4, 2, 1)

I copy pasted the most recent code block you sent and then formatted it according to the screenshot you shared and recieve an error in the terminal relating to your stats variable. Can you copy and paste the entirety of your code block and insert it into the comments to ensure I have what you have as you did not report seeing this error. this is what I have in the code right now.

full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
    if not isinstance(name, str):
        print('The character name should be a string')
    elif not name:
        print('The character should have a name')
    elif len(name) >10:
        print('The character name is too long')
    elif ' ' in name:
        print('The character name should not contain spaces')
stats = \[strength, intelligence, charisma\] 
    for stat in stats:
        if not isinstance(stat, int):
        print('All stats should be integers')
    if stat < 1:
        print('All stats should be no less than 1')
    elif stat > 4:
        print('All stats should be no more than 4')
    elif sum(stats)!= 7:
        print('The character should start with 7 points')
create_character(1, 4, 2, 1)

This is the error I recieved the terminal

Traceback (most recent call last):
  File "main.py", line 12
    stats = \[strength, intelligence, charisma\] 
             ^
SyntaxError: unexpected character after line continuation character

Here is my entire code:

full_dot = ‘●’

empty_dot = ‘○’

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

if not isinstance(name, str):

    print('The character name should be a string')

elif not name:

    print('The character should have a name')

elif len(name) >10:

    print('The character name is too long')

elif ' ' in name:

    print('The character name should not contain spaces')



stats = \[strength, intelligence, charisma\] 



for stat in stats:

    if not isinstance(stat, int):

        print('All stats should be integers')

    if stat < 1:

        print('All stats should be no less than 1')

    elif stat > 4:

        print('All stats should be no more than 4')

    elif sum(stats)!= 7:

        print('The character should start with 7 points')

create_character(1, 4, 2, 1)

you should try and use the print() built-in function to get a more clear view of whats happening.

print(my_function(my_arg1, my_arg2))

can you press the </> button and put your code in there so it is formatted properly

Hi @muneebsaleem3,

You are missing an important bit from the instructions:

the function should return

Edit: There are no returns in your code.

Also, you need to wrap your function call in print() to see what it returns in the console. This will be important when you test the final string returned when all validation checks pass.

Please also keep this in mind when you post your code. We cannot test unformatted code or code that is sent in a screenshot.


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 (').

Happy coding!


thankyou @dhess replacing my “prints” with “returns” passed all but 1 test. I still can’t pass test 10. My latest code is:

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 not 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'



stats = \[strength, intelligence, charisma\] 



for stat in stats:

    if not isinstance(stat, int):

        return'All stats should be integers'

    elif stat < 1:

        return'All stats should be no less than 1'

    elif stat > 4:

        return'All stats should be no more than 4'

    elif sum(stats)!= 7:

        return'The character should start with 7 points'

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

I figured it out. thanks for the help