[Tutor] Accessing a tuple of a dictionary's value
Alan Gauld
alan.gauld at yahoo.co.uk
Fri Aug 24 05:19:32 EDT 2018
On 24/08/18 10:02, Alan Gauld via Tutor wrote:
> CCing list, please always use Reply-All or Reply-List when responding
> to the tutor list so that everyone gets a chance to reply.
>
>
> On 24/08/18 00:35, Roger Lea Scherer wrote:
>>
>> Lots of code missing, but the line I'm interested in is this:
>> print("Your number " + str(numerator) + "/" + str(denominator) + "
>> is approximately " + str(fractions[ranges[i][0]][0]) + "/" +
>> str(fractions[ranges[i][0]][1]))
>> I get this output:
>> Your number 37/112 is approximately 1/3
>>
> print("Your number %d/%d is approximately %d/%d" % (numerator,
> denominator,
> fractions[ranges[i][0]][0],
> fractions[ranges[i][0]][1]))
>
> The stacked layout is of course optional, I just think it looks clearer.
It would look clearer if the mail hadn't messed it up! :-)
The two fractions() lines were intended to be under the
numerator,denominator values not on the left side!
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list