UnboundLocalError: local variable ' ' referenced before assignment - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: UnboundLocalError: local variable ' ' referenced before assignment (/thread-20864.html) Pages:
1
2
|
RE: UnboundLocalError: local variable ' ' referenced before assignment - buran - Sep-03-2019 (Sep-03-2019, 06:46 PM)d3fi Wrote: what does "{....:2f} mean? I understand the {dosis:..} fine. thats the one to be used. this is string formatting specification see https://docs.python.org/3/library/string.html#format-string-syntax .2f means dosis is float number and you want it to be displayed with 2 decimal places precision, e.g.>>> dosis = 1/3 >>> dosis 0.3333333333333333 >>> f'{dosis:.2f}' '0.33' >>> f'{dosis:.4f}' '0.3333' >>> |