Skip to main content
emphasis
Source Link
DinoCoderSaurus
  • 28.6k
  • 2
  • 12
  • 31

This for holding in holdings: processes the first element in holding, and then returns from the function. The return needs "less indent" so it executes when the for loop is complete.

Warning: stocks will hold the values of the last holding processed. (more later).

symbol and shares are always set to the first element (index 0) in holdings (eg symbol = holdings[0]['stock']).symbol and shares are always set to the first element (index 0) in holdings (eg symbol = holdings[0]['stock']).

I'm speculating that index.html iterates over stocks, which has 5 elements, since the output shows 5 rows, but the index route is only sending 1 row.

stocks needs to be some kind of nested object, like a list of dictionaries. Since holdings is already a list of dictionaries consider this - if you add new key/value pairs to holdings (eg holding['name'] = symbolinfo['name']), you could send that to index.html and have everything you need.

This for holding in holdings: processes the first element in holding, and then returns from the function. The return needs "less indent" so it executes when the for loop is complete.

Warning: stocks will hold the values of the last holding processed. (more later).

symbol and shares are always set to the first element (index 0) in holdings (eg symbol = holdings[0]['stock']).

I'm speculating that index.html iterates over stocks, which has 5 elements, since the output shows 5 rows, but the index route is only sending 1 row.

stocks needs to be some kind of nested object, like a list of dictionaries. Since holdings is already a list of dictionaries consider this - if you add new key/value pairs to holdings (eg holding['name'] = symbolinfo['name']), you could send that to index.html and have everything you need.

This for holding in holdings: processes the first element in holding, and then returns from the function. The return needs "less indent" so it executes when the for loop is complete.

Warning: stocks will hold the values of the last holding processed. (more later).

symbol and shares are always set to the first element (index 0) in holdings (eg symbol = holdings[0]['stock']).

I'm speculating that index.html iterates over stocks, which has 5 elements, since the output shows 5 rows, but the index route is only sending 1 row.

stocks needs to be some kind of nested object, like a list of dictionaries. Since holdings is already a list of dictionaries consider this - if you add new key/value pairs to holdings (eg holding['name'] = symbolinfo['name']), you could send that to index.html and have everything you need.

Source Link
DinoCoderSaurus
  • 28.6k
  • 2
  • 12
  • 31

This for holding in holdings: processes the first element in holding, and then returns from the function. The return needs "less indent" so it executes when the for loop is complete.

Warning: stocks will hold the values of the last holding processed. (more later).

symbol and shares are always set to the first element (index 0) in holdings (eg symbol = holdings[0]['stock']).

I'm speculating that index.html iterates over stocks, which has 5 elements, since the output shows 5 rows, but the index route is only sending 1 row.

stocks needs to be some kind of nested object, like a list of dictionaries. Since holdings is already a list of dictionaries consider this - if you add new key/value pairs to holdings (eg holding['name'] = symbolinfo['name']), you could send that to index.html and have everything you need.