Question: I'm working on a project which I want to be able to take words separated by a space, turn it into a string using .split() and then have pyautogui print it out with an "enter" being pressed in between each word. This is the code I have so far below.

```
# Importing stuff
import pyautogui

# Configure Typing Thing
pyautogui.PAUSE = 0

# Input
input = "hi this is a test run of this program"

# generate words
output_list = input.split()

pyautogui.write(output_list)
pyautogui.press("enter")

```

Could someone tell me what I did wrong while writing this? Thanks in advance.

Answer: 
Rather than declaring and incrementing a global variable - you could set the count as a HTML 5 data attribute on the button and then on clicking the button, get the data attribute value, increment it and update the display and the new count on the button.

Note that data-attributes are always strings - hence the need for the parseInt() method, though if I was being a purist - I would have put the radix in as well, but that defaults to 10 - so no need in this case.

It is always better to avoid global variable when possible and data attributes offer a very conveniant way of storing local data.

Thanks to @Sven.hig for the skeletn code of the solution - which I then modified to my approach.

```js
var res=document.getElementById("res")
var btn=document.getElementById("btn")

btn.addEventListener("click",()=>{
  const newCount = parseInt(btn.getAttribute('data-count'))+1;
  res.textContent = newCount;
  btn.setAttribute('data-count', newCount)
})
```

```html
<div id="res"></div>

<button id="btn" data-count="0">Draw</button>
```
Here is a simple example that will give you an idea about how to increment a counter

```js
var res=document.getElementById("res")
var btn=document.getElementById("btn")
var count=1
btn.addEventListener("click",()=>{
    res.textContent=count
    count++

})
```

```html
<div id="res"></div>

<button id="btn">Draw</button>
```