Write python code that reads a string with numbers and letters and outputs sum of the numbers and number of letters.
s = input("Enter input: ") sumOfNumber = 0 numberOfLetters = 0 for x in s: if x>='0' and x<='9': sumOfNumber += int(x) else: numberOfLetters += 1 print("Sum of numbers:",sumOfNumber) print("Number of letters:",numberOfLetters)
Get Answers For Free
Most questions answered within 1 hours.