Skip to content

lesson 14 practice 2 solution refuses to work when typed by hand #1335

Description

when i type the correct code into the practice, the code to decrease the damage does not have any effect at all. this causes the success condition to be unmet as the damage value ends up being wrong when the conditions require the damage value to be correct. this is what happens in the GIF. it is only when i reveal the solution and click on the use solution button that the code actually works even though the code is the exact same as shown in the screenshot

To Reproduce
Steps to reproduce the bug:

  1. type the code i used manually. the code i used is as follows:
var level = 3
var health = 100
var max_health = 100

func take_damage(amount):
	if health > 2:
		amount *= 0.5
	
	health -= amount

	if health < 0:
		health = 0
  1. click run
  2. observe how the health still decreases by the normal amount even when the amount value is multiplied by 0.5
  3. click on the solution button
  4. click on the use solution button
  5. click run
  6. observe how the code now runs properly even though its literally the exact same code that refused to work before
Image here is a GIF displaying how the code refuses to work. Image here is a screenshot showing the code that i typed in alongside the solution code. notice that both are the exact same thing.
  • Operating System: windows 10
  • Browser: Firefox

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions