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 |
|
Why will this code fail?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
List index starts from 0 and for 5 elements it must go from 0 to 4 but in this case the value 5 has been used an hence the code will result in an index error .....