<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div>Hi I'm also new to Python but would like to reply.</div><div><br></div><div>Like others have stated there is a built in function (sum) that can give the sum of the elements of a list, but if what you are trying to do is learn how to use the while command here is some code that will work.</div><div><br></div><div>Your question:</div><div><br></div><div>My question is in a while loop; how do l sum all the numbers in the given list (list_a)?<br><br>list_a = [8, 5, 2, 4]<br>sum_a = 0 # for storing the sum of list_a<br>i = 0 # for looping through the list_a# Use a while loop to sum all numbers in list_a# If you store the sums into sum_a<br>print(sum_a) # should print 19</div><div><br></div><div>My answer:</div><div><br></div><div><p align="LEFT">list_a = [<font color="#800000"><font color="#800000">8</font></font>, <font color="#800000"><font color="#800000">5</font></font>, <font color="#800000"><font color="#800000">2</font></font>, <font color="#800000"><font color="#800000">4</font></font>]</p>
<font color="#0000ff"><font color="#0000ff"></font></font><p align="LEFT"><br></p>
<p align="LEFT"></p>
<p align="LEFT">sum_a = <font color="#800000"><font color="#800000">0</font></font></p><font color="#800000"><font color="#800000">
</font></font><p align="LEFT">i = <font color="#800000"><font color="#800000">0</font></font></p><font color="#800000"><font color="#800000">
</font></font><font color="#0000ff"><font color="#0000ff"></font></font><p align="LEFT"><font color="#0000ff"><font color="#0000ff">while</font></font> i < (len(list_a)):</p>
<p align="LEFT">        sum_a += list_a[i]</p>
<p align="LEFT">        i += <font color="#800000"><font color="#800000">1</font></font></p><p align="LEFT"><font color="#800000"><br></font></p><font color="#800000"><font color="#800000">
</font></font><p align="LEFT">    </p>
<font color="#0000ff"><font color="#0000ff"></font></font><font color="#0000ff"><font color="#0000ff">print</font></font>(sum_a)<BR><br><BR><br><BR></div>                                    </div></body>
</html>