I need to isolate all integers from a string, list them, and print their sum and the # of integers. My issue is that my current code will split, for example, 456 into 4, 5, and 6, and treat them as separate integers. Unfortunately regex is not an option.
What i have so far:
def tally(text):
s = ','.join(x for x in text if x.isdigit())
numbers = [int(x) for x in s.split(",")]
num=len(numbers)
t=sum(numbers)
print ('There are', num, 'integers in the input summing up to', t)
.
What i need: input:'34 ch33se 34e8 3.4'
output: [34 33 34 8 3 4 ]
im getting now is [3 4 3 3 8 3 4]