November 2018
Beginner to intermediate
182 pages
4h 48m
English
How many unique characters can we see?
For reference, ASCII has 127 characters in it, so we expect this to have, at most, 127 characters:
unique_chars = list(set(text))unique_chars.sort()print(unique_chars)print(f'There are {len(unique_chars)} unique characters, including both ASCII and Unicode character')
The preceding code returns the following output:
['\n', ' ', '!', '"', '$', '%', '&', "'", '(', ')', '*', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', ...Read now
Unlock full access