def simon_says(action: str): if action.lower().startswith('simon says') and action[10] in ' ,': return action[len('simon says'):].strip(', "') else: return 'You didn\'t say, "Simon says"!'
import re- def simon_says(action: str):
pattern = re.compile(r'^\b(Simon says,?\s*)(.*)', re.IGNORECASE)match = pattern.search(action)if match and len(match.group(1)) in [11,12]:extracted_text = match.group(2)return extracted_text.strip('"')- if action.lower().startswith('simon says') and action[10] in ' ,':
- return action[len('simon says'):].strip(', "')
- else:
- return 'You didn\'t say, "Simon says"!'