Write a python function that calculates Fibonacci sequence of length n and returns it as…
- User
Write a python function that calculates Fibonacci sequence of length n and returns it as a list.
Assistant
def Fibonacci(n): fib_sequence = [0, 1] if n <= 2: return fib_sequence[:n] else: for i in range(2, n): fib_sequence.append(fib_sequence[i-1] + fib_sequence[i-2]) return fib_sequence
Example usage
n = 10 print(Fibonacci(n))
- User
Is there anything wrong with the code?
Assistant
No, the code is correct as it should be. It returns the Fibonacci sequence of length n as a list.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.