I’ve said all the same lines as the conductor. on the fifth potion it stops and says failing even though he says the exact same thing as the conductor again.
My Code:
var potionsOnTheWall = 10;
var numToTakeDown = 1;
while(true) {
hero.say(potionsOnTheWall + " potions of health on the wall!");
// Sing the next line:
hero.say(potionsOnTheWall + " potions of health!");
// Sing the next line:
hero.say(“take 1 down and pass it around”);
potionsOnTheWall -= numToTakeDown;
// Sing the last line:
hero.say(potionsOnTheWall + " potions of health on the wall!");
}
Nm
answer:
(solution removed)
Glad, you found your answer, it may help to put your code in the ‘code’ format when posting to the forums, that way others can read your code better. It is the symbol on the toolbar for posting that looks like this: < / >
Can you help me find the answer? I just cant find it. Here is my current code.
potionsOnTheWall = 10
numToTakeDown = 1
while True:
self.say(potionsOnTheWall + " potions of health on the wall!")
self.say(potionsOnTheWall + " potions of health!")
self.say(“take” + numToTakeDown + " pass it around!")
potionsOnTheWall -= numToTakeDown
self.say(potionsOnTheWall + " potions of health on the wall!")
Missing " down, …".
hero.say("Take " + numToTakeDown + " down, pass it around!")
Else it would be “Take n pass it around” instead of “Take n down, pass it around”.
Also, be sure to leave spaces in between quotes and variables so it doesn’t end up like “Takendown, pass it around”.
Thanks, I tried it and it worked.
I have the same problem as OP but in Python, and also, hero keeps singing “NaN potions of health”
potionsOnTheWall = 10
numToTakeDown = 1
while True:
hero.say(potionsOnTheWall + " potions of health on the wall!")
# Singe die nächste Strophe:
hero.say(potionsOnTheWall + " potions of health!")
# Singe die nächste Strophe:
hero.say("take one down, pass it around" + potionsOnTheWall-1 + " potions of health on the wall!")
potionsOnTheWall -= numToTakeDown
I also don’t understand why there’s a level requirement to sing the last verse separately - it should get there automatically with this bit of code - if it works as intended.
No, it shouldn’t work the way you’ve written it. The proper way would be to increment the potionsOnTheWall
variable before the last say statement and then call the updated variable. Instead, you’ve incremented inside the say method and then increment after that line.
The first 7 lines of code are right, it’s the rest which are wrong, maybe on the 8th line say "take" + numToTakeDown + "down, pass it around"
and stop there for the rest of the line.
In the 9th line you say potionsOnTheWall -= numToTakeDown
Then you say potionsOnTheWall + "potions of health on the wall!"
Hope this helps.
Why use numToTakeDown
at all in this level? We always wanna take down exactly one, right?
I posted 7 lines of code above, you said they were right. Then, your suggestion:
"take" + numToTakeDown + "down, pass it around"
potionsOnTheWall -= numToTakeDown
hero.say(potionsOnTheWall + " potions of health on the wall!")
doesn’t work!
yeah my mistake you can just say: take one down pass it around.
but apart from that it should/does work.
I used the variable numToTakeDown in that say statement in my original code and it worked fine.
I’ll PM you my code and a screenshot if you want, I’ve already done the level, I’ve got it in front of me.
In that case, the pre-written code (or comments) are misleading: The incrementation (or what do you call it) potionsOnTheWall -= numToTakeDown
is clearly placed to be written after the second (or third) say
statement, as you can see:
I used this now:
potionsOnTheWall = 10
numToTakeDown = 1
while True:
hero.say(potionsOnTheWall + " potions of health on the wall!")
hero.say(potionsOnTheWall + " potions of health!")
# Singe die nächste Strophe:
potionsOnTheWall -= numToTakeDown
hero.say(" take one down, pass it around " + potionsOnTheWall + " potions of health on the wall!")
It behaves as expected, but doesn’t beat the level.
potionsOnTheWall = 10
numToTakeDown = 1
while True:
hero.say(potionsOnTheWall + " potions of health on the wall!")
# Sing the next line:
hero.say(potionsOnTheWall + " potions of health!")
# Sing the next line:
hero.say(“Take " + numToTakeDown + " down, pass it around!”)
potionsOnTheWall -= numToTakeDown
# Sing the last line:
hero.say(potionsOnTheWall + " potion of health on the wall!")
I code it! And still failing :)) why? Please help me!!!
please format your code properly using the button and putting you code in the paste or type your code here.
The variable works, but I don’t understand what it’s for, because its value doesn’t vary.
Yes, if you could please, that would be great
No, it places the increment exactly where it should be. Your original code posted above places it after the third say statement, not where it should be.
Unanswered questions:
- Why that extra instruction to “sing the last verse”?
- Why the need for a numToTakeDown variable?
- What are the exact requirements for beating the level, i.e. what is the exact text that should be produced in order to count as a valid sing-along?
In the screenshot above, there are three yellow arrows, each pointing to one comment with instructions what to do (“sing the xth verse”). Under each of these comments, there’s one line of emtpy space.
This combination of arrows, instructions and empty spaces leads me to believe that I’m supposed to write my say
statements where the empty spaces are.
Would you say this is a stupid way of seeing it?
Anyways, if I follow this logic and do put one say
statement in each of these empty lines, then that places potionsOnTheWall -= numToTakeDown
after the 3rd say
statement.
That’s what I meant be this being misleading.
potionsOnTheWall = 10
numToTakeDown = 1
while True:
hero.say(potionsOnTheWall + " potions of health on the wall!")
hero.say(potionsOnTheWall + " potions of health!")
hero.say("Take " + numToTakeDown + " down, pass it around!")
potionsOnTheWall -= numToTakeDown
hero.say(potionsOnTheWall + " potion of health on the wall.")
Yeah, I code like this! but error! Code can run and stop at 5 potion