Why does a set of double quote comment have effect on real code
Question:
This is the code which be reported error unexpexted indentation
(because of the comment YOUR CODE HERE
double quoted)
while score0 < goal and score1 < goal:
if who == 0:
num_rolls = strategy0(score0, score1)
score0 += take_turn(num_rolls, score1, dice)
who = other(who) if extra_turn(score0, score1) == False else who
else:
num_rolls = strategy1(score1, score0)
score1 += take_turn(num_rolls, score0, dice)
who = other(who) if extra_turn(score1, score0) == False else who
"*** YOUR CODE HERE ***"
when I delete the "*** YOUR CODE HERE ***"
(same indentation level of while) ,everything works fine.
By the way ,I have never seen a comment with a set of double quote(" "
).Maybe common format of comment is like """ """
or #
Answer: the "*** YOUR CODE HERE ***"
is a string literal.
Answers:
That isn’t a comment, it’s a string literal
It still works because it is a string, or more specifically a string literal:
A string literal or anonymous string is a type of literal for the representation of a string value in the source code of a computer program. Source
Putting a string like so in the code does absolute nothing, unless put in a function or assignment.
This is the code which be reported error unexpexted indentation
(because of the comment YOUR CODE HERE
double quoted)
while score0 < goal and score1 < goal:
if who == 0:
num_rolls = strategy0(score0, score1)
score0 += take_turn(num_rolls, score1, dice)
who = other(who) if extra_turn(score0, score1) == False else who
else:
num_rolls = strategy1(score1, score0)
score1 += take_turn(num_rolls, score0, dice)
who = other(who) if extra_turn(score1, score0) == False else who
"*** YOUR CODE HERE ***"
when I delete the "*** YOUR CODE HERE ***"
(same indentation level of while) ,everything works fine.
By the way ,I have never seen a comment with a set of double quote(" "
).Maybe common format of comment is like """ """
or #
Answer: the "*** YOUR CODE HERE ***"
is a string literal.
That isn’t a comment, it’s a string literal
It still works because it is a string, or more specifically a string literal:
A string literal or anonymous string is a type of literal for the representation of a string value in the source code of a computer program. Source
Putting a string like so in the code does absolute nothing, unless put in a function or assignment.