Aug-20-2021, 09:07 AM
In the homework section, a Cesar cypher is presented.
A string of symbols is provided:
But as you can see, this is far from complete on the punctuation side, thus forcing us to write code,
in case a symbol from the cypher is not found. Fine, you can do that. (e.g. comma, hyphen...)
I thought of doing this, to make list more complete and generic:
Of course it is possible to choose and "pop" one before adding string.punctuation to symbols, but is there a better way?
(Make a list instead?)
Paul
A string of symbols is provided:
1 |
SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?.' |
in case a symbol from the cypher is not found. Fine, you can do that. (e.g. comma, hyphen...)
I thought of doing this, to make list more complete and generic:
1 2 |
import string symbols = ' ' + string.ascii_letters + string.digits + string.punctuation |
Output:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
Only, the string .punctuation contains both ' and ", making the program wonder where the symbols string starts and ends.Of course it is possible to choose and "pop" one before adding string.punctuation to symbols, but is there a better way?
(Make a list instead?)
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.