Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ascii question
#1
In the homework section, a Cesar cypher is presented.
A string of symbols is provided:
SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?.'
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:
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'.
Reply


Messages In This Thread
ascii question - by DPaul - Aug-20-2021, 09:07 AM
RE: ascii question - by Gribouillis - Aug-20-2021, 09:27 AM
RE: ascii question - by snippsat - Aug-20-2021, 09:56 AM
RE: ascii question - by Larz60+ - Aug-20-2021, 10:11 AM
RE: ascii question - by DPaul - Aug-20-2021, 04:07 PM
RE: ascii question - by Yoriz - Aug-20-2021, 04:19 PM
RE: ascii question - by DPaul - Aug-20-2021, 05:32 PM
RE: ascii question - by naughtyCat - Aug-21-2021, 01:47 PM
RE: ascii question - by perfringo - Aug-21-2021, 05:50 PM
RE: ascii question - by Yoriz - Aug-21-2021, 05:58 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020