TDT4109/Exercise 4 - Inspera/13.py

8 lines
165 B
Python

import re
def count_letters(string):
try:
assert bool(re.match('^\w+$', string))
return len(string)
except AssertionError:
return -1