if statement - Python Else Pass -


hey got small script should check code of bunch of pages , send msg via pushbullet if specific string found depending on page string found else should nothing.

this got modify work if else pass problem me atm.

import urllib import time pushbullet import device  string = 'this test string' b = 1 phone = device('apikey', 'devicekey')  while b <= 10:     webpage = urllib.urlopen('http://thisisawebpage.com').read()     website = urllib.urlopen('http://thisisawebsite.com').read()     phone.push_note("string found" , "string found") if string in webpage else pass     phone.push_note("string found in website" , "string found in website") if string in website else pass     time.sleep(1800) 

the if-else here expression, not statement, cannot use pass. conditional expression used when need 1 of 2 values, depending on condition; not control-flow statement. use proper if statement instead.

if string in webpage:     phone.push_note("string found", "string found") if string in website:     phone.push_note("string found in website", "string found in website") 

if know perl, python conditional expression looks similar perl's if statement modifier, 2 not equivalent. in perl, like

# pseudo-perl; there no `in` operator , perl replacement # depends heavily on $webpage $phone->push_note("string found", "string found") if $string in $webpage; 

will work, not in python.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -