This is my part of the code:
import functions
def assign_tasks(operators, requests, current_time):
sort_requests(requests)
print(requests)
The error is:
NameError: name 'sort_requests' is not defined
The function module has the following functions:
def sort_requests(requests):
requests.sort(key=operator.itemgetter(3),reverse=True)
return requests
def sort_operators_hours(operators):
operators.sort(key=operator.itemgetter(4))
return operators
2 Answers 2
add from functions import sort_requests or replace sort_requests(requests) by functions.sort_requests(requests)
Sign up to request clarification or add additional context in comments.
Comments
First : Check your import statement. Is it function or functions.IT should be the name of your python file name.
Second : your function sort_requests has a return statement. U need to store the returned output.Try this
import functions
def assign_tasks(operators, requests, current_time):
requests = sort_requests(requests)
print(requests)
Comments
lang-py
functions.sort_request(requests)or change your import line:from functions import sort_requests