File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 22Convert a given ASCII value to its corresponding character.
33"""
44
5+
56def ascii_to_char (ascii_value : int ) -> str :
67 """
78 Converts an ASCII integer value to its character equivalent.
@@ -15,6 +16,7 @@ def ascii_to_char(ascii_value: int) -> str:
1516 """
1617 return chr (ascii_value )
1718
19+
1820if __name__ == "__main__" :
1921 import doctest
2022
@@ -24,8 +26,10 @@ def ascii_to_char(ascii_value: int) -> str:
2426 try :
2527 ascii_val = int (input_value )
2628 if 0 <= ascii_val <= 127 :
27- print (f"The character for ASCII value { ascii_val } is: { ascii_to_char (ascii_val )} " )
29+ print (
30+ f"The character for ASCII value { ascii_val } is: { ascii_to_char (ascii_val )} "
31+ )
2832 else :
2933 print ("Please enter a valid ASCII value (0-127)." )
3034 except ValueError :
31- print ("Invalid input. Please enter an integer." )
35+ print ("Invalid input. Please enter an integer." )
You can’t perform that action at this time.
0 commit comments