coding : utf-8
def sum_numbers(text: str) -> int:
test1=""
figure="0123456789"
summ=0
space=False
number=False
for i in range(len(text)) : # checking caracters
for j in range(len(figure)) : # checking figures
alpha=text[i]
_ **cool=figure[j]**_
if alpha==cool :
number=True
if (number and figure) or (number and figure==False): #recontruction of the number
test1=test1+alpha
figure=True
elif(number==False and figure) or (i==len(text)-1): #conversion and addition
summ=summ+int(test1)
figure=False
number=False
return summ
print("Example:")
print(sum_numbers("hi. I'm 40 and he's 200. Ok?"))
""" We have a "TypeError: 'bool' object is not subscriptable" when we compile the program.
When does the "cool" String variable become boolean??? How to fixed this error? """
Created at: 2023/03/16 22:39; Updated at: 2023/03/17 14:44
The question is resolved.