How to use the trinket console

You will find an interactive Python console like the one below to code your solutions to the challenge:

  1. Use this drop-down menu to choose between ‘Run’ mode or ‘Interactive console’ mode. In the ‘Run’ mode, you will see the output of what you’ve written but you will not be able to write in the left side (the terminal). In the ‘Interactive console’ mode, you will be able to write new code and do more testing directly in the terminal. Use the ‘▶’ or ‘>’ button to re-run your code when you make new changes or in case something goes wrong.
  2. This is the terminal. The outputs and prints are shown here. If you are using the ‘Interactive console’ mode, you will be able to write new lines of code and get their output on the go.

FAQs

If you encounter some of these situations when writing and testing your code:

  • “I got the message “Connection to server timed out. Run trinket again to reconnect.” on the terminal.”
  • “Sometimes, if I write something wrong, I cannot write something new again.”
  • “Sometimes, after entering a line of code, I cannot see the “>>>” lines.”

Refresh the console by clicking the following button:

In the “Run” mode, you will need to print the output of your function to see it in the console. In order to interactively see the code that is being executed and write new lines for immediate results /without the need of calling print()), change to “Interactive console” mode.

Select the whole block of code from def your_function() until the return (return included), and select “copy” with the right mouse button. If you do this, when you paste it on the testing console, you should be able to see “…” in each of the lines of the block of code. The ‘…’ represents indentation.

In Python, indentation refers to the spaces at the beginning of a code line and they are used to indicate a block of code. You can use ‘tabs’ or ‘spaces’ for this purpose; however, in the trinket console, we recommend you to use ‘tabs’.

Make sure to be consistent with the indentation when writing your code. Use the ‘tab’ key on the current line or, for automatic indentation of the next line of code, use the ‘enter’ key. Be careful with the syntax, otherwise, the automatic indentation may be wrong. In the interactive console, the indentation is represented by ‘…’.

It means that you are ready to use the function check.check() to validate your code. This is an example of how it should look in the interactive console: