import re with open('HealBot_Action.xml', 'r') as f: content = f.read() buttons_42_50 = '\n'.join([f'