Not sure how to achieve point number 7, 9, 10 and 12 for the RPG challenge.
Failed:7. The create_character function should not say that the character is too long when it’s not longer than 10 characters.
Failed:9. When create_character is called with a first argument that does not contain a space it should not return The character name should not contain spaces.
10. When create_character is called with a second, third or fourth argument that is not an integer it should return All stats should be integers.
12. When create_character is called with a second, third or fourth argument that is lower than 1 it should return All stats should be no less than 1.
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(name, strength, intelligence, charisma):
#Name validations
if not isinstance(name,str):
return "The character name should be a string"
if name == '':
return "The character should have a name"
if len(name) >= 10:
return 'The character name is too long'
if name.count("") > 0:
return "The character name should not contain spaces"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Failed:7. The create_character function should not say that the character is too long when it’s not longer than 10 characters.
Failed:9. When create_character is called with a first argument that does not contain a space it should not return The character name should not contain spaces.
Focus on resolving these two failed tests. You have not written code to implement all of the user stories yet.
Here are some debugging steps you can follow. Focus on one test at a time:
Are there any errors or messages in the console?
What is the requirement of the failing test?
Check the related User Story and ensure it’s followed precisely.
What line of code implements this?
What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)
If this does not help you solve the problem, please reply with answers to these questions.
I managed to progress some small steps. Now Im looking at slimming down my code so it is more in essence with the simple Python vibe..
Trying to solve: Failed:9. When create_character is called with a first argument that does not contain a space it should not return The character name should not contain spaces.
Failed:10. When create_character is called with a second, third or fourth argument that is not an integer it should return All stats should be integers.
def create_character(name, strenght, intelligence, charisma):
if not isinstance(name,str):
return "The character name should be a string"
if name == '':
return "The character should have a name"
if (len(name)) > 10:
return "The character name is too long"
if name.find (" "):
return "The character name should not contain spaces"
if not name.find (" "):
return
if not isinstance(strength, int) and not isinstance(intelligence, int) and not isinstance(charisma, int):
return "All stats should be integers"
if not isinstance(strength, int) < 1 and not isinstance(intelligence, int) <1 and not isinstance(charisma, int) <1:
return "All stats should be no less than 1"