Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in continue statement
#1
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"] = apply 
I 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?
Reply
#2
always paste the entire unaltered error traceback. It contains valuable information.
the line number you show does not match displayed code.

the continue you show in the script should be ok.
again show full error that matched code.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 656 Sep-05-2023, 12:50 PM
Last Post: ToniE
  Error in Using INPUT statement gunwaba 1 2,016 Jul-03-2022, 10:22 PM
Last Post: deanhystad
  List Creation and Position of Continue Statement In Regular Expression Code new_coder_231013 3 1,602 Jun-15-2022, 12:00 PM
Last Post: new_coder_231013
  Cryptic Error with import statement Led_Zeppelin 2 2,479 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Indentation Error With If Else Statement JoeDainton123 3 1,777 Aug-02-2020, 08:29 PM
Last Post: deanhystad
  syntax error on return statement l_butler 5 3,027 May-31-2020, 02:26 PM
Last Post: pyzyx3qwerty
  Syntax Error (elif statement) Kanashi 0 3,638 Nov-20-2019, 11:29 PM
Last Post: Kanashi
  Error with simple "or" statement? Mark17 4 2,266 Nov-15-2019, 05:16 PM
Last Post: Mark17
  error using 'continue' in my code ilcaa72 1 2,025 Jun-05-2019, 08:05 PM
Last Post: vindo
  Attribute error print statement error jamshaid1997 1 2,427 Jan-20-2019, 04:02 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020