Coding Challenge
Let’s solve a small coding challenge in Python while using Transcrypt.
We'll cover the following
Problem statement
Currently our application can add and remove text from within an HTML element.
In this code challenge, we will be starting with hello.py
and hello.html
. We will add two new buttons where one button turns the color of the displayed text to red, and another that turns the color of the displayed text to blue.
Similar to how we used .innerHTML
to set the element text, use the .style.color
element property to set the color. .style.color
can be changed to any color, by setting it to the string name of the color—for example,. "blue"
.
Don’t forget to run the transcrypt
command to regenerate the JavaScript code after we’ve made the changes to the Python code.
Get hands-on with 1200+ tech skills courses.