Python: findall Function - # 2
Posted: Fri Aug 15, 2025 7:29 am
Code: Select all
import re
title = "Hosting Chatter vs Mad Hatter"
instances_of_atter_in_title = re.findall("atter", title)
# displays
# ['atter'], ['atter']
#:because the nonsense word is found two times
Code: Select all
import re
band_name = "Shocking Blue"
instances_of_word_Red_in_band_name = re.findall("Red", band_name)
# displays
# []
# because "Red" is not found in band_name