ValueError: chr() arg not in range(0x110000)

13,512

Maybe when you subtract 18 from original ascii value, it goes out of range,i.e, less than 0.

Share:
13,512

Related videos on Youtube

Wyatt
Author by

Wyatt

Updated on June 17, 2022

Comments

  • Wyatt
    Wyatt 6 months

    Writing a decoding program and keep running into

    ValueError: chr() arg not in range(0x110000)

    when I input the string I need to decode. The input string is:

    [2ea^W_`^k2eiWSd2fZSf2[2S_2gb2fa2`[email protected]
    

    The code is as follows currently:

    # String manipulation
    # This program accepts a string and an integer
    # then decodes the number of lines by a know decryption key
    # Initialize the program and necessary variable
    print("This progam can decode an encrypted by a known encryption key")
    string=""
    decoded_message=""
    coded_message=""
    # Prompting the used for input using a for loop to accept multiple lines
    coded_message=input("What is the line to be decoded?")
    # Using a for loop, the messges will be decrypted character
    # at at time to its ASCII value then decrypted and converted
    # back to text
    for string in coded_message:
        converted_text=ord(string)
        decryption=(chr(converted_text-18))
        decoded_message+=decryption
    # Output the decoded message
    print("Your decrypted message is:",decoded_message)
    

    I'm sure I'm missing something simple but any help would be great

  • Wyatt
    Wyatt over 6 years
    Turns out this was the problem. The message we were being given to test had a space in it that was not supposed to be there.

Related