Zero for the Odd Reply

Python for AIEasy+10 XP+10

Zero for the Odd Reply

A survey stores replies as text. Most are whole numbers, like "34". Some are not, like "twenty" or "".

Write to_number(reply) that returns the reply as a whole number. If int() can't read it, return 0 instead of crashing.

Examples

reply = "34"
returns 34
reply = "twenty"
returns 0
reply = "-5"
returns -5

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run