Build an RPG Character - Build an RPG Character

Tell us what’s happening:

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

Challenge Information:

Build an RPG Character - Build an RPG Character

Hi @walter.carl.stuart ,

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:

  1. Are there any errors or messages in the console?
  2. What is the requirement of the failing test?
  3. Check the related User Story and ensure it’s followed precisely.
  4. What line of code implements this?
  5. 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.

Happy coding!

1 Like

Hi @walter.carl.stuart

In addition to the advice from @dhess, add the following print call after the function to help you debug.

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

Happy coding

2 Likes