input: Write a python function to generate a Fibonacci sequence up to a given number and return it as a list.
  assert generate_fibonacci(10) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
  assert generate_fibonacci(5) == [0, 1, 1, 2, 3]
  assert generate_fibonacci(1) == [0]
  assert generate_fibonacci(0) == []
output: def generate_fibonacci(n):
      if n <= 0:
          return []
      fib_sequence = [0, 1]
      while len(fib_sequence) < n:
          fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])
      return fib_sequence[:n]