Feedback: Deja Brew

Thank you. I’m completely stumped. I can’t see where I’m messing up with my code.

potionsOnTheWall = 10
numToTakeDown = 1
while True:
    hero.say(potionsOnTheWall + " potions of health on the wall!")
    # Sing the next line:
    hero.say(potionsOnTheWall + " potion of health!")
    # Sing the next line:
    hero.say("Take " + numToTakeDown + " down, pass it around!")
    potionsOnTheWall -= numToTakeDown
    # Sing the last line:
    hero.say(potionsOnTheWall + " potions of health on the wall.")

Use Search


In two of displayed topics you can find the answer of your question.

1 Like

oh my I knew I’d feel stupid. I forgot an s. Thank you.

What am I doing wrong with 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 " + numToTakeDown + " down, pass it around!");
    potionsOnTheWall -= numToTakeDown;
    // Sing the last line:
    hero.say(potionsOnTheWall - numToTakeDown + " potions of health on the wall.");
}

Nick, pay very close attention to your ‘+’ and ‘-’ signs…

Thanks dedreous, can you be more specific because still I don’t get what I’m doing wrong?

Look at these two lines:

Do you think it’s a good idea to minus numToTakeDown of PotionsOnTheWall twice?
Danny

I don’t know…

But I don’t know what’s wrong with that as well.

I tried other combinations as well but nothing works, I don’t get what the answer on this tbh.

What I was trying to say was that you should only minus it when redefining the variable not also when saying your message. You can just say the potions variable by itself. (along with potions of health on the wall of course)

Now I got it!

Thanks Deadpool198

1 Like

Copy and paste this:
Mod edit: please don’t post solutions.

Hi @jude_divinemask8, welcome to the CodeCombat Discourse! :tada:
Thank you for posting and trying to help nova777, but on this forum we don’t give out solutions – it ruins the point of the game. Instead of letting them win without learning anything, you should help them understand their problem and then they’ll be able to solve future levels and will be better at coding.
That’s why I’ve removed your code,
Thanks,
Danny

1 Like