Fibonacci sequence using list in PYTHON?

前端 未结 6 1434
清酒与你
清酒与你 2020-12-16 08:48

I have a problem about making a fibonacci sequence to a list, I\'m just new to python someone help me please.

This is my code. I know this is looking wrong or somet

6条回答
  •  被撕碎了的回忆
    2020-12-16 09:19

    This code puts the first 700 fibonacci numbers in a list. Using meaningful variable names helps improve readability!

    fibonacci_numbers = [0, 1]
    for i in range(2,700):
        fibonacci_numbers.append(fibonacci_numbers[i-1]+fibonacci_numbers[i-2])
    

    Note: If you're using Python < 3, use xrange instead of range.

提交回复
热议问题