'How to write if else inside an if...else statement in python?
i am new to python and in this code i want to check if bid_data[8]
not equal to '' then the below code runs otherwise only
bidno = bid_data[0].split(":")[-1]
should runs
if (idx % 2 == 1):
bid_data = extracted_data.contents[idx].text.strip().split('\n')
bidno = bid_data[0].split(":")[-1]
items = bid_data[8].split(":")[-1]
qnty = int(bid_data[9].split(':')[1].strip())
dept = (bid_data[10] + bid_data[15].strip()).split(":")[-1]
edate = bid_data[20].split("End Date:")[-1]
Solution 1:[1]
if (idx % 2 == 1):
bid_data = extracted_data.contents[idx].text.strip().split('\n')
if bid_data[8] != '':
bidno = bid_data[0].split(":")[-1]
items = bid_data[8].split(":")[-1]
qnty = int(bid_data[9].split(':')[1].strip())
dept = (bid_data[10] + bid_data[15].strip()).split(":")[-1]
edate = bid_data[20].split("End Date:")[-1]
else:
bidno = bid_data[0].split(":")[-1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dharman |