Build an RPG character - Build an RPG Character

This is what I am trying now using the 3 stat separately. Console has no warning. but does not pass.

if not isinstance(strength,int):

   return "all stats should be integers"

if not isinstance(intelligence,int):      return "all stats should be integers"

if not isinstance(charisma,int):

   return "all stats should be integers"

consider if you are returning the right message, each character is important, so check capitalization and punctuation, those are the usual culprits

but also, have you added print(create_character("al", '',3,4)) to your editor to see what your function does? can you tell me what get printed for this?

Yes I did try that does not help.

Below is the latest. No alert in terminal the new 3 lines do not pass.

stats={‘STR’:strength,‘INT’:intelligence,‘CHA’:charisma}

if not isinstance(strength,int):

   return "All stats should be integers"

if len (strengh)<1:

     return "All stats should be no less than 1"

if len (strength)>4:

     return "The character should start with 7 points"

can you give all your code including function definition?

here:

def create_character(

    name,

    strength,

    intelligence,

    charisma):

    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={'STR':strength,'INT':intelligence,'CHA':charisma}

    if not isinstance(strength,int):

       return "All stats should be integers"

    if len (strengh)<1:

         return "All stats should be no less than 1"

    if len (strength)>4:

         return "The character should start with 7 points"

I’ve edited your post to improve the readability of the code. 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 (').

please add a function call to your editor, like print(create_character("name", '', 2, 5));

and look at what your function is returning, and tell us what you see

if you refuse to do this, we are unable to help you forward

Added as below. Terminal shows “syntax error”

print (ceate_character(“name”,“”, 2,5)):

stats={'STR':strength,'INT':intelligence,'CHA':charisma}

if not isinstance(strength,int):

   return "All stats should be integers"

if len (strengh)<1:

     return "All stats should be no less than 1"

if len (strength)>4:

     return "The character should start with 7 points"

you need to add it after the function, you also still need the function declaration with def, please do not delete code

please review the different between creating a function and calling a function

Regret I am still here , I have defined a function to validate stats

Below is a snippet.

return"The character name should not contain spaces"

def validate_stats(stats):

stats={"STR":strength,

“INT”:intelligence, “CHA”:charisma}

if not isinstance("STR",int):

     return "All stats should be integers"

Still does not pass. Please help.

please post all your function, not a snippet, also please format it properly

you can add the print call at the bottom of the editor to see what is being returned by your function

you must see what your function is returning so you know where to investigate. it keeps not passi g because you are failing to investigate and making changes to the wrong part of the function

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 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):

   print (create_character, strength,int)

   return"All stats should be integers"

There is no alert in the terminal, but it still does not pass.

If you are not going to add a print to check what your function returns you are not going to receive anymore help from me

write the function call at the end of your editor, and you will see what your function returns, if you don’t do that, I am not going to return to this topic

print(create_character("name", '', 2, 5))

add this, and tell us what your function is returning for this case, it’s the only way to go forward. You need to know what your function is doing instead of just guessing.

1 Like
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 len (name)>10:

       return"The character name is too long"

    if ''in (name):

       return"The character name should not contain spaces"

def validate_stats(stats):       

    stats={"STR":strength,

   "INT":intelligence, "CHA":charisma}

    for key, value in stats.items():

        if not isinstance("STR", int):

            return "All stats should be integers"

        if "STR" < 1:

            return "All stats should be less than 1"

            print (create_character("STR", '',2,5))

Terminal clear. Still does not pass. Please help. I have been here for 2 days now>

you need to put the print not inside the function, at the start of the line, no spaces in front

also please format your code, it’s unreadable

1 Like

Note I am not going to format your code again, please take the responsaibility to make your code readable to to others.

I’ve edited your post to improve the readability of the code. 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 (').

here how you need to put the print call:

def create_character(...):
  ...

print(create_character("name", '', 2, 5))

it needs to go after the function as first thing on the line, no spaces before the print

return “Stats are valid”

Here is what I have now still does not pass at an early point. No activity in the terminal. I have been stuck here for days. I tried starting from beginning twice.

Please help.

that string does not appear anywhere in the code you posted, did you change your code?

can you show how you are using print to test your function?

1 Like

that’s because you are not calling your function, please call your function and use print so you can see what your function is returning

1 Like