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?
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"
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.
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"
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
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.
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>
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.
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.