Question: I'm having problems calculating and displaying a number in an input field via jquery.
considering I have two input fields, the first one accepts a number and the second one displays this number + 100. works as it should do, as long as you enter the number in the first field via the keyboard. changing the number with the little arrow buttons on the right side of the input field however, doesn't always refresh the second input field at once, especially if you try to "hammer" those little arrow buttons: if you keep clicking them, the number isn't refreshed, until you move the mouse (tested with win 10 and google chrome).

I have found several topics regarding this problem and tried different approaches (see commented code lines), none of them work for that case.

```js
$(document).ready(function() {
  $('#inp_1').on('keyup', function() {
    calc();
  });

  $('#inp_1').on('change', function() {
    calc();
  });

  function calc() {
    var old_val = parseInt($('#inp_1').val());
    var new_val = old_val + 100;

    $('#inp_2').val(new_val);

    /*
    $("#inp_2").attr('value', new_val);
    $("#inp_2").trigger("change");
    */

    //$("#inp_2").attr('defaultValue', newVal);
  }
});
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="number" step="1" id="inp_1" value="">
<input type="number" step="1" id="inp_2" value="">
```

Answer: 
(complex)One liner:

```
>>> def successive_items(s):
        return [x for x in s.split() if any(x[i]==x[i-1] for i in range(1,len(x)))]

>>> successive_items('baaaaah mooh lpo mpoo')
['baaaaah', 'mooh', 'mpoo']
>>> successive_items('hgj kio mpoo')
['mpoo']

```

In case of your code, you should not modify the list you are iterating over. Say, for example, lets have an array:

```
a = [1,2,3,4,5]

```

Now, if you iterate and remove elements (inside the loop), you would expect `a` to be empty. But let's check out:

```
>>> a = [1,2,3,4,5]
>>> for item in a:
        a.remove(item)

>>> a
[2, 4]

```

See? It is not empty. This is better explained [here](https://stackoverflow.com/questions/6260089/strange-result-when-removing-item-from-a-list#answer-6260097).

Your program is not working for the second case because of list modification. Here is how:

1. Initially your list had `['hgj','kio','mpoo']`.
2. After reading the first element you removed `hgj`. So the list now becomes `['kio','mpoo']`.
3. The loop iterates the 2nd element next, and it gets `mpoo` (in the modified list);
4. `kio` was never read.
This might help:

```
sentence = input("please enter your text")

words = sentence.split()

answers = []
for each_word in words:
    for idx in range(1, len(each_word)):
        if each_word[idx] == each_word[idx-1]:
            answers.append(each_word)
            break

print(answers)

```

In your code, you are iterating over a list and at the same time you are modifying that very same list(by deleting elements from it), for more explanation see [this answer](https://stackoverflow.com/a/10665602/5341013)