1

this is my piece of code which outputs at input clues[0] = '706965':

x = clues[0]
answer = bytes.fromhex(x).decode("ascii")
<class 'ValueError'>, ValueError('non-hexadecimal number found in fromhex() arg at position 5')

If I add 0 to to clues[0] it outputs the expected output with first char with offset.

x = '0'+clues[0]

The output then is '[]ie'. The [] means special char(stackoverflow ommits it).

but if i run this example in terminal everything works fine.

>>> x = '706965'
>>> bytes.fromhex(x).decode("ascii")
'pie'

Solved: Parsing error

1 Answer 1

1

From the docs for bytes.fromhex

This bytes class method returns a bytes object, decoding the given string object. The string must contain two hexadecimal digits per byte, with ASCII whitespace being ignored.

Prepending '0' to your string makes it length seven, so it can't consist of two-digit pairs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.