Read a Python runtime error
Start with the last line: it names the error and often the missing value. Then find the last solution.py frame to locate your own code. NameError means a name was not defined in the current scope. Read input and assign it before using it. A runtime error is different from a wrong answer: the program did not finish normally. Avoid catching every exception, because that hides the useful traceback.
import json
def solve(data):
values = data["values"]
n = len(values)
return {"length": n}
assert solve({"values": [3, 5]}) == {"length": 2}
# In the editor: print(json.dumps(solve(json.loads(input()))))These examples use Python 3 and include assertions you can run locally.
Try an original practice problem