Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
4 years, 4 months ago
I'm having some serious trouble getting the index function to iterate through each of the user's stocks to obtain the current market price. It correctly outputs a list of the user's stocks along with the sum of shares owned of each stock, but I can't get it to output the current price of each stock (and also the total current value of each stock). Any help would be very much appreciated as always.
Link to the code and the html page:
Nov 5, 2018 at 5:12
17 4 4 bronze badges
index () function
returns during the first iteration of your
for loop. At that point, you have only looked up the price for the first symbol.
You should collect the price and value for all symbols in the portfolio before the function returns.
Nov 5, 2018 at 6:35
Peter Pesch Peter Pesch
999 6 6 silver badges 16 16 bronze badges
log in to answer this question.
Not the answer you're looking for? Browse other questions tagged
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only