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 8837703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:47:44+00:00 2026-06-14T09:47:44+00:00

I copied the source code of a python program written by someone else on

  • 0

I copied the source code of a python program written by someone else on a tutorial forum and I have made a few modifications to it to match my own needs

the original was meant to run in the python shell i believe and i got it to run in the shell but I need to save it to python IDLE and run it from there

I am using python 3.2.3 IDLE btw
this is what I have written:

def fibonacci(previous=0,current=1):
    n = int(input("Calculate fibonacci sequence value up to: "))
    if previous > current:
        previous,current = current, previous
    yield previous
    yield current
    while True:
        current,previous = previous+current,current
        yield current

    x = fibonacci()    
    for i in range(n):
        print(next(x))
fibonacci()

it doesn’t run, like no errors pop up i just get the arrows: >>
that’s it nothing happens.

  • 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-14T09:47:45+00:00Added an answer on June 14, 2026 at 9:47 am

    The program does start and runs through. Unfortunately, by using yield in the function, you make it a generator, and the generator gets only constructed in the last line, but never evaluated.

    Instead, you want to outdent the last four lines:

    def fibonacci(previous=0,current=1):
        if previous > current:
            previous,current = current, previous
        yield previous
        yield current
        while True:
            current,previous = previous+current,current
            yield current
    
    n = int(input("Calculate fibonacci sequence value up to: "))
    x = fibonacci()    
    for i in range(n):
        print(next(x))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Someone copied my website, and in the source code, obviously is there the Analytics
I copied and pasted a certain source code into my program with a text
I've a source code(test.cpp) that supposed to display three images(color, grayscale and canny) copied
I have this code copied from C# 4.0 in a nutshell that uses Attribute/Reflection
I have a few Python packages that I would like to tidy up and
I currently have my ASP.NET and C# source code versioned using a local Debian
I have copied source from the answer of this question and have created this
I copied the generated source code ( View Source -> View Generated Source in
I just copied over an Visual Studio 2010 source code from one SVN repository
I have PHP source code of http://www.sitename.com . This site is located on Windows

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.