Write a program that asks the user for a number. If it is between 1 and 255, output the corresponding ASCII character. If it is outside of that range, output "Out of range"
Sample Run
Enter a number between 1 and 255: 97
a
Enter a number between 1 and 255: 256
Out of range
1
Expert's answer
2019-11-05T07:41:56-0500
while True:
char = int(input("Enter a number between 1 and 255: "))
if 1 <= char <= 255:
x = chr(char)
print(x)
break
else:
print("Out of range")
Comments
Leave a comment