Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
try except solution in Uncategorized category for Sum Numbers by Antoni_Wojcik
def sum_numbers(text: str) -> int:
tab = text.split()
counter = 0
for x in tab:
try:
x = int(x)
if isinstance(x,int):
counter += x
except:
pass
return counter
print("Example:")
print(sum_numbers("hi"))
assert sum_numbers("hi") == 0
assert sum_numbers("who is 1st here") == 0
assert sum_numbers("my numbers is 2") == 2
assert (
sum_numbers(
"This picture is an oil on canvas painting by Danish artist Anna Petersen between 1845 and 1910 year"
)
== 3755
)
assert sum_numbers("5 plus 6 is") == 11
assert sum_numbers("") == 0
print("The mission is done! Click 'Check Solution' to earn rewards!")
Nov. 22, 2022