Feb-02-2020, 12:54 PM
(This post was last modified: Feb-02-2020, 12:54 PM by Man_from_India.)
for i in range(len(openings)): # Extraction job description opening = openings[i].find_all("p") # To check if final result is announced for this job if '(Final Result Announced)' in opening[0].text: continue description = opening[0].text.split('(') if len(description)>2: job_description = description[0] + '- ' + description[1].split(')')[0] else: job_description = description[0] my_dictionary["job_description"] = job_description # Extracting advertisement number advertisement = opening[1].text.split('(')[1].split(')')[0] my_dictionary["adv_no"] = advertisement[18:] # Extracting links to download advertisement from download_advertisement_and_apply = links[i].find_all("a") download_advertisement = 'https://sbi.co.in/' + download_advertisement_and_apply[0].get('href') my_dictionary["adv_link"] = download_advertisement # Extracting links to apply online apply = download_advertisement_and_apply[1].get('href') my_dictionary["apply_link"] = applyI know when i = 8, the following code
advertisement = opening[1].text.split('(')[1].split(')')[0]
(Line 21)
will give error.
Error:list index out of range
But I used a if
loop and used continue statement
(Line 10) and technically it should break from the for
loop and should not execute the part outside the if
statement for i = 8. Why am I getting the error? And how to solve it?