[Tutor] Times Tables Program that constantly tells you that you are wrong!

Peter Otten __peter__ at web.de
Thu Aug 23 08:32:51 EDT 2018


Matthew Polack wrote:

> I'm also trying to solve the rounding issue...but can't work out the
> syntax using the example provided...have tried this but I get an error...
> 
> _tkinter.TclError: unknown option "-text %.2f"
> 
> .I'm sure it is a simple syntax issue...but I don't know what it is.
> 
> def viewPercent():
>      percentCalc = score/total*100
>      percentViewLab["text %.2f"] % percentCalc

I'm sure you can resolve that one yourself. You have

obj[key] = float_value

Now you want to format the float value as a string showing a decimal number.
So all you need to change is the righthand side. If it helps write it in two 
lines:

some_string = ... expression involving float_value ...
obj[key] = some_string



More information about the Tutor mailing list