12080 instead of 200 — I laughed out loud BEBellaRossiOP 25 Sep, 09:32 Never seen addition produce that. So "120" + "80" just glues the text together?
EMEmmaCodes25 Sep, 17:32replies: 2Yep, + on strings means concatenation. Data from sensors, files, input() and APIs often arrives as text, so converting with int() or float() is step one.
BEBellaRossiOP27 Sep, 07:55replies: 1That explains a bug I had in an actual spreadsheet export script last month.
OLOliviaPy27 Sep, 20:51And for decimals in stage 3, float(), not int() — int("98.5") throws an error.
Comments 4
Join the discussion CommentAlready have an account? Log in
Yep,
+on strings means concatenation. Data from sensors, files, input() and APIs often arrives as text, so converting withint()orfloat()is step one.That explains a bug I had in an actual spreadsheet export script last month.
And for decimals in stage 3,
float(), notint()— int("98.5") throws an error.type()is your best friend whenever numbers act weird.