<div dir="ltr"><div><div>Hi again,<br><br></div>Still working leisurely through the tutorial here:<br><a href="http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/io.html">http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/io.html</a><br>
<br></div>An excise at the end of second 1.10 says to <br clear="all"><div><div><div>Write a version of the quotient problem in <a class="" href="http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/io.html#quotientproblem"><em>Exercise for Quotients</em></a>,
<tt class=""><span class="">quotientformat.py</span></tt>, that uses the string format method to
construct the same final string as before. Again be sure to give a full sentence
stating both the integer quotient and the remainder.<br><br><br></div><div>So I did <br><br>x=int(input('Enter an integer '))<br>y=int(input('Enter another integer '))<br>z=int(input('Enter a third integer '))<br>
formatStr='Integer {0}, {1}, {2}, and the sum is {3}.'<br>equations=formatStr.format(x,y,z,x+y+z)<br>print(equations)<br>formatStr2='{0} divided by {1} is {2} with a reminder of {3}'<br>equations2=formatStr2.format(x,y,x//y,x%y)<br>
print(equations2)<br><br></div><div>And obviously this works. <br></div><div>But the question is: if I want to keep the results of {2} and {3} between the first instance (formatStr) and the second (formatStr2) how would I go about it? Apprently using {4} and {5} instead results in a index sequence error as in<br>
<br>IndexError: tuple index out of range<br><br></div><div>/Martin S<br></div><div>--<br>Regards,<br><br>Martin S
</div></div></div></div>