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.
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 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.
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.
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?
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 :=