I had a pass up to validating stats and could not move and ended up restarting because I deleted the beginning, so I reset and was confident I would pass forward.
I am now at the very beginning. What am I doing wrong? Console says indentation error. I had broken up the arguments into two lines and indented properly, then I kept getting syntax error.
Traceback (most recent call last):
File "main.py", line 7
charisma):
^
IndentationError: expected an indented block after function definition on line 3
There is nothing in your function so you are getting an error. There’s no code, so there’s not indent.
The pass keyword in a function is used when we define a function but don’t want to implement its logic immediately. It allows the function to be syntactically valid, even though it doesn’t perform any actions yet.
So far the console does not show any mishaps, but my attempt passed only the first test.
Your code so far
full_dot = '●'
empty_dot = '○'
def create_character(
name,
strength,
intelligence,
charisma):
pass
def create_character():
if not isinstance(name, int):
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"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0
full_dot = '●'
empty_dot = '○'
def create_character(
name,
strength,
intelligence,
charisma):
pass
if not isinstance(name,int):
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"
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.
There is no alert in the console, but the test does not pass at this point.
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 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}
for stats in stat.value():
if not isinstance(stat,int): return"All stats should be integers"
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
do you see what your function is returning for this case? create_character("al", '',3,4)
look at the terminal, what it’s written there? where does that come from? which line(s) cause that message to be printed?