How to check if the string is empty or blank?
import re from collections import Counter sentence = 'Canada is located in the northern part of North America' # Example I counter = len(re.findall("a", sentence)) print(counter) # Example II counter = sentence.count('a') print(counter) # Example III counter = Counter(sentence) print(counter['a'])
Sample output of above program.
Empty
Empty
Empty
2018-07-26T12:09:57+05:30
2018-07-26T12:09:57+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution