-
Notifications
You must be signed in to change notification settings - Fork 1
/
AwaSCII Converter from ASCII to Decimal (multiple characters)
32 lines (28 loc) · 1.45 KB
/
AwaSCII Converter from ASCII to Decimal (multiple characters)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# AwaSCII Converter from ASCII to Decimal
# Dictionary mapping ASCII values to their corresponding decimal keys
value_to_dec = {
'A': 0, 'W': 1, 'a': 2, 'w': 3, 'J': 4, 'E': 5, 'L': 6, 'Y': 7, 'H': 8, 'O': 9,
'S': 10, 'I': 11, 'U': 12, 'M': 13, 'j': 14, 'e': 15, 'l': 16, 'y': 17, 'h': 18,
'o': 19, 's': 20, 'i': 21, 'u': 22, 'm': 23, 'P': 24, 'C': 25, 'N': 26, 'T': 27,
'p': 28, 'c': 29, 'n': 30, 't': 31, 'B': 32, 'D': 33, 'F': 34, 'G': 35, 'R': 36,
'b': 37, 'd': 38, 'f': 39, 'g': 40, 'r': 41, '0': 42, '1': 43, '2': 44, '3': 45,
'4': 46, '5': 47, '6': 48, '7': 49, '8': 50, '9': 51, ' ': 52, '.': 53, ',': 54,
'!': 55, '`': 56, '(': 57, ')': 58, '~': 59, '_': 60, '/': 61, ';': 62, '\n': 63
}
# Function to get the decimal value based on the ASCII character
def get_decimal(ascii_char):
return value_to_dec.get(ascii_char, "Invalid character")
def main():
print("AwaSCII Converter from ASCII to Decimal")
while True:
ascii_input = input("Enter ASCII characters (or 'exit' to quit): ")
if ascii_input.lower() == 'exit':
print("Exiting AwaSCII Converter. Goodbye!")
break
decimal_values = [str(get_decimal(char)) for char in ascii_input]
if "Invalid character" in decimal_values:
print("Invalid input. Please enter valid ASCII characters.")
else:
print("The decimal values are: " + " ".join(decimal_values))
if __name__ == "__main__":
main()