<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Blowing up things!
So far we learned about functions, conditions and loops. Lets use our knowledge so far to do something fun - blow up things!
In this adventure we will build structures with TNT. Once we are done building with TNT and we are ready we'll explode the TNT.
Lets get started ...
Step1:  Task 1
Step2:  Task 2
Step3:  We need to run the function you  defined in Task 2 using the following statement. 
python
thread.start_new_thread(placeTNTBlock,())
We need to do so since we are going to toggle the buildingWithTNT variable as the program is running. 
Note
<ASSISTANT_TASK:>
Python Code:
# Run this once before starting your tasks
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
import thread
mc = minecraft.Minecraft.create()
Explanation: Blowing up things!
So far we learned about functions, conditions and loops. Lets use our knowledge so far to do something fun - blow up things!
In this adventure we will build structures with TNT. Once we are done building with TNT and we are ready we'll explode the TNT.
Lets get started ...
End of explanation
# Task 1 code
# add a variable with an initial value
# toggle the variable
# print the value of the variable 
Explanation: Task 1: Toggling TNT building
We need to know when Steve is building a TNT structure and when he is done building and just wants to move around in the world. There are two phases when Steve is moving around
Steve is moving to build with TNT
Steve is moving around normally and is not building with TNT
We use a variable named buildingWithTNT and set it to the value True when Steve is in the building phase and set the variable to False when he is not building with TNT. Note that the variable takes only two values True and False. When the current value of the variable is True, the next value it should take is False and when the current value is False, the next value the variable should take is True. This technique of setting the next value of the variable to the opposite of its current value is called toggling. In Python an easy way to toggle a boolean variable is shown below
python
myvariable = False # initial value
myvariable = not myvariable # toggles value
Complete the program below to add the variable buildingWithTNT and toggle the variable when run and verify your program runs correctly by printing the variable value with a string like 'buildingWithTNT = False'.
End of explanation
# Task 2 code
Explanation: Task 2: Building with TNT
To build with TNT blocks, we first have to toggle the buildingWithTNT variable by executing the Task1 code block. This will toggle buildingWithTNT to True. Then Steve has to run (or jump or fly) wherever he wants to place the TNT blocks. Once we are done building, we have to toggle the buildingWithTNT variable again by executing the Task1 code block again. This will now toggle the buildingWithTNT variable to False and Steve will now move normally.
Lets write the function placeTNTBlock that will set the block that Steve is currently on to a TNT block. A TNT block has the id block.TNT.id. Remember that in order to define a function, one needs to use def Its a good idea to review functions in Adventure 3 before you write the function placeTNTBlock.
Make sure that in your function, you set a TNT block only if the buildingWithTNT variable is set to True. Use an if conditional to do so. Your program should look like the one below
```python
def myfunction():
    while True:
        time.sleep(0.1)
        pos = mc.player.getTilePos()
        # if buildingWithTNT is True set the block at the current position to block.TNT.id
```
 Great Job
End of explanation
# Run Task 2 function on using thread.start_new_thread
Explanation: We need to run the function you  defined in Task 2 using the following statement. 
python
thread.start_new_thread(placeTNTBlock,())
We need to do so since we are going to toggle the buildingWithTNT variable as the program is running. 
Note: Ask your instructor for help if you get stuck running your program or run into errors!
End of explanation
<END_TASK>