Hi again,

Still working leisurely through the tutorial here:

An excise at the end of second 1.10 says to
Write a version of the quotient problem in *Exercise for Quotients*
quotientformat.py, 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.

So I did

x=int(input('Enter an integer '))
y=int(input('Enter another integer '))
z=int(input('Enter a third integer '))
formatStr='Integer {0}, {1}, {2}, and the sum is {3}.'
formatStr2='{0} divided by {1} is {2} with a reminder of {3}'

And obviously this works.
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

IndexError: tuple index out of range

/Martin S

Martin S

Reply via email to