Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- pattern = r"!([A-Z][a-z]{2,})!:\[([A-Za-z]{8,})\]"
- n = int(input())
- for _ in range(n):
- text = input()
- match = re.search(pattern, text)
- if not match:
- print("The message is invalid")
- else:
- command = match.group(1)
- string = match.group(2)
- ascii_list = [str(ord(s)) for s in string]
- print(f"{command}: {' '.join(ascii_list)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement