Is this a bug or a typo? Walrus operator, "Known Enemy" dungeon

This is the hints menu;

Declaring a variable with method 2 and method 3 does not work. My code is literally one line to declare enemy1 and it throws an error.

I’ve been having issues since yesterday. Are these typos in the hints menu? Which version of Python is CodeCombat working on? I read that walrus := is from Python 3.8 onwards.

Your code probably isn’t correct. Could you post it using the </> button?

(def enemy1 "Kratt")

Results in;

enemy1 := "Kratt"

All I did was to copy-paste from the hints menu.

I tried two separate computers, one Windows PC with Firefox which I am writing this comment on, and earlier I had the same problems on my Chromebook (Pixelbook Go, latest Chrome update).

Yep, your code’s wrong. Try not to copy/paste from the hints. They can help, but don’t give you the code. Start over the level, so you have the starting code, and try again. If you run into any problems, you can look back at previous levels, and/or ask for more help.

So the hints are wrong.

Wow. What quality control.

1 Like

No the hints aren’t wrong, they just don’t give you the code. You need to learn how to code!

Well yeah! That’s why I’m here!

I just wanted to declare one variable with walrus and it doesn’t work!

so the variables in this level are given. That means you just need to write the attack code. but put your variable inside the () in hero.attack(). That way your hero knows who to attack.

so restart the level, and try doing it yourself!

Yes I know that but I’m not here to play the game. I want to learn what the code means and what it does.

I tried using the walrus operator and nothing works. Can you show me how := works with basic variables that won’t make the game throw an error? I just want to declare enemy1. I can spam poor code and finish the level but I’m here to learn Python syntax.

1 Like

ok, so to make a variable, it’s ‘=’ not ‘:=
for instance, enemy1 = "Kratt" defines enemy1 as “Kratt”. so instaed of using “Kratt” over and over, you can just use enemy1, and it will do the same thing.

Can you help with the walrus operator? If not, where can I get more information? Who knows how to use it?

Is this not working because it’s an invalid use case or something? Is this only for functions and it’s breaking because I’m attempting to declare a variable?

If you continue in the game, it will teach you these things over time, but you need to play the game to do it.
and sorry, but I don’t know what the walrus operator is.
@Chaboi_3000, @Deadpool198, @Alexbrand you are the current leaders, can you help?

I don’t think CoCo even teaches this “walrus operation.”

complete the level, answer the guy and don’t summon the admins
and this is closure:
but it’s not supported now

Ah ok completed thanks xython. So I guess the := is for Lua.

Okay, sorry.

The walrus operator can be used for python as well. It defines a variable and does something with it on the same line of code, but I prefer just using = instead of :=

1 Like

Yes, checked What’s New In Python 3.8 and this will work in it but not in CoCo python:

1 Like