I have similar list of if statements like this that repeat the same pattern. How can I crunch this code to make it look better and not be so monstrous?
header = driver.find_element(By.CLASS_NAME, "header")
if (header):
print header.get_attribute("class") + present
else:
print header.get_attribute("class") + not_present
t = driver.find_element(By.CLASS_NAME, "t")
if (t):
print t.get_attribute("class") + present
else:
print t.get_attribute("class") + not_present
origin = driver.find_element(By.CLASS_NAME, "origin")
if (origin):
print origin.get_attribute("class") + present
else:
print origin.get_attribute("class") + not_present
desk= driver.find_element(By.CLASS_NAME, "desk")
if (desk):
print desk.get_attribute("class") + present
else:
print desk.get_attribute("class") + not_present
act = driver.find_element(By.CLASS_NAME, "act")
if (act):
print act.get_attribute("class") + present
else:
print act.get_attribute("class") + not_present
originatoranddestinationdefined?