input: Write a function to calculate the maximum possible revenue from items with given weights and values, considering a knapsack with a specific capacity. The function should return the maximum value that can be obtained by selecting items without exceeding the knapsack's capacity. If there are no items or the capacity is zero, return 0.
  assert knapsack([2, 1, 3], [4, 2, 3], 3)==7
  assert knapsack([1, 2, 3], [6, 10, 12], 3)==22
  assert knapsack([1, 2, 4], [1, 4, 5], 3)==9
  assert knapsack([], [], 0)==0
  assert knapsack([1, 3, 4, 5], [1, 4, 5, 7], 4)==13
output: def knapsack(weights, values, capacity):
      n = len(weights)
      if n == 0 or capacity == 0:
          return 0
      
      dp = [[0] * (capacity + 1) for _ in range(n + 1)]
      
      for i in range(1, n + 1):
          for w in range(1, capacity + 1):
              if weights[i-1] <= w:
                  dp[i][w] = max(dp[i-1][w], dp[i-1][w-weights[i-1]] + values[i-1])
              else:
                  dp[i][w] = dp[i-1][w]
      
      return dp[n][capacity]