Python: findall Function - # 2

Post Reply
User avatar
The Jason
Site Admin
Posts: 853
Joined: Tue Jul 01, 2025 10:13 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


 

POSTREACT(ions) SUMMARY

Post Reply