TypeError on Python. Missing1 required positional argument

I'm writing a script to pull data using an API, and attach the results to a list.

I have af unction to create a list and return it, and I want to use this list in another function, which will append the data from the API to the list.

My code so far is:

import bigcommerce

# Script used to pull Orders data from the Big Commerce API.

# login to bigcommerce api
api = bigcommerce.api.BigcommerceApi(host='*****.mybigcommerce.com', basic_auth=('*************', '**********'))


# create lists
def createList():
    ordersList = list()
    return ordersList


# loop over the list and get the orders with the IDs
def pullOrders(ordersList):
    #  remember to update range (higest so far: 615982)
    for x in range(614534, 615982):
        try:
            ordersList.append(api.Orders.get(id="{}".format(x)))
        except:
            pass
    return ordersList

createList()
pullOrders()

When I try to run it, I get this error:

TypeError: pullOrders() missing 1 required positional argument: 'ordersList'

Upvotes: 0

Views: 370

Answers (1)

levi
levi

Reputation: 22697

You forgot pass the created list to pullOrders

  list = createList()
  pullOrders(list)

Upvotes: 1

Related Questions