Q:

Python | Assign Hexadecimal values in the string and print it in the string format

belongs to collection: Python String Programs

0

Example:

    Input:
    str = "\x41\x42\x43\x44"
    Output:
    str = "ABCD"

    Input:
    str = "This is  \x49\x6E\x63\x6C\x75\x64\x65\x48\x65\x6C\x70"
    Output:
    str = "This is  IncludeHelp"

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

# python program to assign hexadecimal values
# to the string

# declare and assign strings
str1 = "\x41\x42\x43\x44"
str2 = "This is  \x49\x6E\x63\x6C\x75\x64\x65\x48\x65\x6C\x70"

# printing strings
print("str1 =", str1)
print("str2 =", str2)

Output

str1 = ABCD
str2 = This is  IncludeHelp 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python String Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python | How to print double quotes with the strin... >>
<< Python | Check if a substring presents in a string...