String classification¶
Save all these functions in file classify.py
Write function
class1()that, given a text (str), returnsTrueif it contains only lowercase letters andFalseotherwise. Examples:>>> class1('Hi John') False >>> class1('three cars') False >>> class1('diamond') True >>> class1('CLUE') False >>> class1('sweter') True
Note
More tests are provided in file
test-class1.txtWrite function
class2()that, given a text (str), returnsTrueif it represents a real amount andFalseotherwise. Examples:>>> class2('Bye. Alex') False >>> class2('0.0') True >>> class2('34.53€') False >>> class2('123.0') True >>> class2('Price: 45.8') False >>> class2('8723.6512') True >>> class2('234567') False >>> class2('0.') True
Note
More tests are provided in file
test-class2.txt
Solution
A solution is provided in file
classify.py.