-4
from webbot import Browser
import time
import pyautogui
from pyautogui import *
web = Browser()
a == True
web.go_to('http://au.yahoo.com//')
web.scrolly(100)
if a == True:
    try:
        web.click('Skip for now')
        break
web.click('Mail')
time.sleep(10)
pyautogui.keyDown('ctrl')

break keeps coming up with unexpected error

I want it to try click 'skip for now', if not then continue the code

  • Look up how to properly use `try`. (Hint: what should the program do if the code in the `try` fails?) – Scott Hunter Apr 11 '21 at 11:34
  • break is meant to break free of a loop. As there is no loop here break doesn't work and so brings error. If you want your program to continue just don't put a break. And when you call for a try you should mention exception so as mentioned below write at least except : pass – Apo Apr 11 '21 at 11:35
  • @Apo but then it comes up with an error – Cam Butcher Apr 11 '21 at 11:38

2 Answers2

1
try:
    web.click("Skip for now")
except:
    pass
Diogo
  • 101
  • 3
-1
web = Browser()
a == True
web.go_to('http://au.yahoo.com//')
web.scrolly(100)
if a == True:
    try:
        web.click('Skip for now')
    except:
        pass
web.click('Mail')
time.sleep(10)
pyautogui.keyDown('ctrl')

EDIT : miss spell of except

Apo
  • 338
  • 1
  • 9