Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = """Put your submission here between the triple quotes for testing.
- This is a sample multiline string with a backspace char \b to show how
- any errors you have will be displayed"""
- # ord finds the numeric value of a character for testing
- valid_chars = [9,10,11,12,13] + list(range(32, 127))
- all_valid = True
- print()
- for i, c in enumerate(s):
- if ord(c) not in valid_chars:
- all_valid = False
- print("Oops, character", c, "with ordinal value:", ord(c), "at position", i)
- print("Its the middle char here: ", '"' + s[i-7: i] + '_' + s[i+1: i+8] + '"')
- print(f"\nAll characters were {'' if all_valid else 'NOT '}valid printable ASCII")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement