Question: I'm new to this forum and python, any help is greatly appreciated.

I'm trying to add a if statement under FOR LOOP, as my code shows below, at the moment, my mouse moves to 4 spots before it closes the current web tab, and it repeats this for 10 times.

My question is how to add a if statement ie. if the right arrow key is pressed while the mouse is moving, it skips a few line of codes and goes straight to the last four line of codes?

The current tab is closed and it moves onto the next tab, until it finishes it's 10 cycles. This new If statement helps to close the browser tab much quicker with human intervention instead of waiting for the whole 8 seconds.

Thank you.

```
import pyautogui as pg
import time, pyautogui
import keyboard

from pynput.keyboard import Key, Listener
pg.moveTo(2679, 900)
pg.click()

for i in range (10):
    pg.moveTo(2679, 1620, duration=2)
    pg.moveTo(2679, 1923, duration=2)
    pg.moveTo(1365, 1875, duration=2)
    pg.moveTo(1365, 1572, duration=2)
    pg.keyDown('ctrl')
    pg.keyDown('w')
    pg.keyUp('w')
    pg.keyUp('ctrl')

```

Answer: 
You can iterate over the values of the dictionary using `.values()` as:

```
view_list = {'24169': '11h', '31254': '14h', '16155': '1d', '4565': '1d', '165929': '2d', '12906': '3d'}

for val in view_list.values():
    if "w" in val:
        print("week")
    if "d" in val:
        print("day")

```

Output:

```
day
day
day
day

```
This might be a "pythonic" solution:

```
any('d' in v for k,v in view_list.items())

```