Learn Flask - Tourist Attractions Project - Step 10

I’m having trouble with the Tourist Attractions Project for Learn Flask

Step 10 mentions to replace [(None, None)] with request.form.items()

Hence my code is

if request.method == “POST”:
[(name, action)] = request.form.items()

When I click on ‘X’ i get an error message saying
ValueError: not enough values to unpack (expected 1, got 0)

Is this right?

I think this is a type in the instructions (though I haven’t done the exercise). If you get to use the terminal interface with these exercises that’s the first place to troubleshoot.

However, since that might not be the case, I leave you this clue:

>>> test = {"hello": 1, "world": 2}
>>> test.items()
[('world', 2), ('hello', 1)]
>>> (x,y) = test.items()
>>> x
('world', 2)
>>> y
('hello', 1)
>>> [(x,y)] = test.items()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack

Notice methodology:

  • get error
  • isolate the error data types (dictionaries and the items() method in this case)
  • try to replicate the error