Post History
Assign floats while leaving out zeroes Python allows such strange assignment. You can save bytes by removing the number preceding . if it's only 0: i=.5 print(i) Try it online! The same g...
#1: Initial revision
# Assign `float`s while leaving out zeroes
Python allows such strange assignment.
You can save bytes by removing the number preceding `.` if it's only `0`:
<!-- language-all: lang-python -->
i=.5
print(i)
[Try it online!][TIO-ktbh15ng]
[TIO-ktbh15ng]: https://tio.run/##K6gsycjPM/7/P9NWz5SroCgzr0QjU/P/fwA "Python 3 – Try It Online"
The same goes for succeeding digits, if the decimal part of the `float` is `0`:
<!-- language-all: lang-python -->
i=5.
print(i)
[Try it online!][TIO-ktbh2pnr]
[TIO-ktbh2pnr]: https://tio.run/##K6gsycjPM/7/P9PWVI@roCgzr0QjU/P/fwA "Python 3 – Try It Online"
You can't assign something with only `.` though, which is unfortunate.
