Bug Fix

The Type Mismatch Crash

The Type Mismatch Crash

Bug Report

A function tries to build a receipt message by adding a price (a number) directly to a string. Instead of a nice message, it crashes with a TypeError.

Type CoercionStringsTypeError
Fix the Bug: The Type Mismatch Crash

Unlike JavaScript, Python does NOT automatically convert numbers to strings (or vice versa) with the '+' operator. Mixing a str and an int with '+' raises a TypeError because Python refuses to silently coerce types — you must convert explicitly.

EditorPython · JSX
PreviewUpdates on Run Tests
Loading preview…
Tests
Should explicitly convert price using str()
Should NOT concatenate price directly without conversion
Should keep the same function signature