promptdojo_

Write a function called safe_int that takes one argument text and returns int(text) if it parses, or the integer 0 if it raises a ValueError. Then call it twice and print the results:

print(safe_int("42"))
print(safe_int("hello"))

Expected output:

42
0

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.