|
|
|
|
@@ -22,15 +22,15 @@ def main(argv: list[str]):
|
|
|
|
|
print("AssertionError:", err)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char_count = len(msg)
|
|
|
|
|
print("The text contains", char_count,"characters:")
|
|
|
|
|
print("The text contains", char_count, "characters:")
|
|
|
|
|
|
|
|
|
|
# filter() https://docs.python.org/3.10/library/functions.html#filter
|
|
|
|
|
upper_count = len(list(filter(str.isupper, msg)))
|
|
|
|
|
print(upper_count, "upper letters")
|
|
|
|
|
|
|
|
|
|
# generator expressions https://docs.python.org/3.10/reference/expressions.html#generator-expressions
|
|
|
|
|
# generator expressions
|
|
|
|
|
# https://docs.python.org/3.10/reference/expressions.html#generator-expressions
|
|
|
|
|
lower_count = sum(1 for char in msg if char.islower())
|
|
|
|
|
print(lower_count, "lower letters")
|
|
|
|
|
|
|
|
|
|
@@ -39,11 +39,13 @@ def main(argv: list[str]):
|
|
|
|
|
punctuation_count = sum(1 for char in msg if char in punctuation)
|
|
|
|
|
print(punctuation_count, "punctuation marks")
|
|
|
|
|
|
|
|
|
|
# array.count() https://docs.python.org/3.10/library/array.html?highlight=count#array.array.count
|
|
|
|
|
# array.count()
|
|
|
|
|
# https://docs.python.org/3.10/library/array.html?highlight=count#array.array.count
|
|
|
|
|
space_count = msg.count(" ") + msg.count("\n")
|
|
|
|
|
print(space_count, "spaces")
|
|
|
|
|
|
|
|
|
|
# list comprehension https://docs.python.org/3.10/tutorial/datastructures.html#list-comprehensions
|
|
|
|
|
# list comprehension
|
|
|
|
|
# https://docs.python.org/3.10/tutorial/datastructures.html#list-comprehensions
|
|
|
|
|
digits_count = len([char for char in msg if char.isdigit()])
|
|
|
|
|
print(digits_count, "digits")
|
|
|
|
|
|
|
|
|
|
|