What They Never Told You About Programming - Part 4

Graham has written a "dump" function to sell all the shares of his tech stocks in case of bad news in the market. However, he hasn't tested his code, and he's made an important mistake:

1
2
3
    tech_stocks=["AAPL","IBM","GOOG","ORCL","HPQ"]      
    for stock in 1,2,3,4,5:     
        sell_shares(tech_stocks[stock])     

Why will this code fail?

×

Problem Loading...

Note Loading...

Set Loading...