First, my code is printing FALSE on the terminal.
second, I keep getting error message to validate the empty string
Your code so far
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 isinstance (name, str):
return not '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 ' ' in name:
return 'The character name should not contain spaces'
for stats in [strength, intelligence, charisma]:
if not isinstance(stats, int):
return 'All stats should be integers'
if stats < 1:
return 'All stats should be no less than 1'
if stats > 4:
return 'All stats should be no more than 4'
if sum(stats) < 7:
return 'The character should start with 7 points'
print (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/122.0.0.0 Safari/537.36
What do you think will be returned if you negate a string? And why do you have two validation checks to make sure name is a string?
Isn’t stats just one integer value the way you’ve written it? And even if it wasn’t, should it be inside a loop?
Edit: Almost forgot, and this is important, function definitions and function calls are written with no space between the name of the function and the opening parenthesis: function(, not function (
Thank you so much. I have edited the function call and definition. I have also worked on the loop. what I now have in NONE on the terminal when I call the function. How do i make you see my updated code please?
There are two ways you can format your code to make it easier to read and test when you post it:
After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)
Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.
To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor: