So in this mission I am supposed to find numbers in the text and make a sum of them. I find them properly (still need to adjust it to see if there is a space after it or not) but I get an error when I try to convert the text.
I did try to debug it, it finds it correctly, no spaces, just the number, I cut it out of the main text even, still unable to convert the string to int, however doing something like
x = "a"
a = int(a)
this works just fine, bellow is my super messy code(will polish it ofc once I can get past this thing), trying to find out what am I doing wrong but honestly idk whats wrong with it, I get an error on line 45, using pycharm : ValueError: invalid literal for int() with base 10: ''
text = "5 plus 6 is"
numbers = []
sum = 0
subtext = ""
start = 0
end = 0
aux = 0
x = len(text)
aux = int(sum)
print(aux+2)
for i in range(x):
if text[i] >= "0" and text[i] <= "9":
start = i
end = 0
for j in range(i,x):
if text[j] >= "0" and text[j] <= "9":
end += 1
else:
break
print("*" + text[i:i+end:1] + "*")
subtext = text[i:end:1]
print(subtext)
sum = int(subtext)
numbers.append(int(sum))
end = 0
print(numbers)
Created at: 2021/09/02 11:59; Updated at: 2021/09/07 09:30