Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8422027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:19:14+00:00 2026-06-10T03:19:14+00:00

I’m writting some code in which I try to check every number in a

  • 0

I’m writting some code in which I try to check every number in a range using a for loop and an if statement. The loop stops after the first check, and throws an error with message wrong type ,,None,, expected integer, I’ll give you what I have been asked to do:

Define a function findLine(prog, target) to perform the following. Assume prog is a list of strings containing a BASIC program, like the type generated by getBASIC(); assume target is a string containing a line number, which is the target of a GOTO statement. The function should return the index i (a number between 0 and len(prog)-1) such that prog[i] is the line whose label equals target. Hint
Sample input/output: If you call
findLine([’10 GOTO 20′,’20 END’], ’10’)

def findLine(prog, target):
  L=[]
  for i in range(0, len(prog)):
     L=L+prog[i].split()
  for j in range(0,len(L)):
     i=L.index(L[j])
     if j == int(target):
       i=i//3
       return i

These is some information :

Running findLine(['10 GOTO 20', '20 END'], '20')… Error: findLine(['10 GOTO 20', '20 END'], '20') has wrong type "None" Type, expected Integer
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:19:15+00:00Added an answer on June 10, 2026 at 3:19 am

    The loop isn’t stopping after the first check: instead, it’s never successfully returning. This function returns based on the following loop:

    for j in range(0,len(L)):
        i=L.index(L[j])
        if j == int(target):
            i=i//3
            return i 
    

    But if the condition j == int(target) is never satisfied, the loop will finish, and the function findLine will return None.

    ETA: Now that you’ve explained what the task is: your construction of the L list isn’t the right way to go about the problem:

      for i in range(0, len(prog)):
         L=L+prog[i].split()
    

    This will produce ['10', 'GOTO', '20', '20', 'END']. In this case, you don’t know which line is which! Still, splitting it is the right direction. What if you just add the label from each split line:

      for i in range(0, len(prog)):
         L.append(prog[i].split()[0])
    

    That will produce an L equal to ['10', '20'], which is much closer to what you’re looking for. The last step would be to get the index of the target in that array (which you already know how to do!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.