Your question is Hex String Check. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Zebra DataWedge integrations may receive diagnostic payloads represented as hexadecimal bytes. Implement a validator that determines whether an input string is a valid hexadecimal byte string.
A valid string contains one or more hexadecimal digits, 0-9, a-f, or A-F. It may optionally begin with 0x or 0X. After removing that prefix, the string must contain an even number of hexadecimal digits because each byte requires two digits. Do not accept whitespace, signs, separators, an empty string, or a prefix without digits.
Given a string s, return True if it satisfies the rules above; otherwise return False. The input is a Python str, and the output is a Boolean.
def is_hex_payload(s):