1#!/usr/bin/env python3
2
3
4# Question 13
5# Level 2
6
7# Question:
8# Write a program that accepts a sentence and calculate the number of letters and digits.
9# Suppose the following input is supplied to the program:
10# hello world! 123
11# Then, the output should be:
12# LETTERS 10
13# DIGITS 3
14
15# Hints:
16# In case of input data being supplied to the question, it should be assumed to be a console input.
17
18
19sentence = input("Enter a sentence with letters and digits:\n")
20digits_count = 0
21letters_count = 0
22
23for c in sentence:
24 if c.isdigit():
25 digits_count = digits_count + 1
26 elif c.isalpha():
27 letters_count = letters_count + 1
28
29print("LETTERS: " + str(letters_count))
30print("DIGITS: " + str(digits_count))