This function receives as input a string which may contain letters, digits or special symbols.The function should return the sum of adding the digits in the string.
An example addDigitsInString('a12bcd3') should return 6
def func(test_str): '''deal with the str''' standard_list = [] for i in range(10): standard_list.append(str(i)) sum = 0 for str_ in test_str: if str_ in standard_list: sum = sum + int(str_) return sum
if __name__ == '__main__': test_str = 'da1asda5ad3ad2' value = func(test_str) print(value)