Code Yarns β€πŸ‘¨β€πŸ’»
Tech Blog ❖ Personal Blog

Python: Division operator gotcha

πŸ“… 2009-Oct-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ division, python ⬩ πŸ“š Archive

/ does true division by default in Python 3

# Use // for integer (or floor) division
# See PEP 238 for details
inta = 5
intb = 3
intc = inta / intbΒ  # 1.6666666666666667
intd = inta // intb # 1