Python Forum
Can someone please help me convert this simple C ROT cipher code to Python code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can someone please help me convert this simple C ROT cipher code to Python code?
#4
The first thing you should do is define some input/outputs. Some test strings, and what you expect the rotated values to be. Does "z" become 'm' or 'M', for example. What does whitespace rotate to? Digits?

From there, the string module is probably the next best place to look.
>>> import string
>>> dir(string)
['Formatter', 'Template', '_ChainMap', '_TemplateMetaclass', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_re', '_string', 'ascii_letters', 'ascii_lowercase', 'ascii_uppercase', 'capwords', 'digits', 'hexdigits', 'octdigits', 'printable', 'punctuation', 'whitespace']
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
Reply


Messages In This Thread
RE: Can someone please help me convert this simple C ROT cipher code to Python code? - by nilamo - Jun-13-2019, 09:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mathematica code vs Python MiloChocolatito 0 462 Mar-31-2025, 06:32 AM
Last Post: MiloChocolatito
  I am getting an IndentError on my python code in VS Code and i dont know why jcardenas1980 11 3,861 Mar-22-2025, 09:49 AM
Last Post: Pedroski55
  I trying to automate the Variable Logon button using the python code but I couldn't surendrasamudrala 0 262 Mar-07-2025, 05:02 AM
Last Post: surendrasamudrala
  How do i run python code? smattiko83 5 660 Mar-06-2025, 09:20 PM
Last Post: ArchieLinux
  Simple code not working properly tmv 2 486 Feb-28-2025, 09:27 PM
Last Post: deanhystad
  I'm new to Python - can someone help with this code as it is not working? lminc123 1 512 Feb-13-2025, 06:13 PM
Last Post: lminc123
  How to convert while loop to for loop in my code? tatahuft 4 805 Dec-21-2024, 07:59 AM
Last Post: snippsat
  I cannot create a virtual environment on visual studio code using python Willem_Aucamp316 2 3,153 Nov-27-2024, 02:20 PM
Last Post: menator01
  CLI to python code azxo1 11 2,147 Oct-21-2024, 08:32 AM
Last Post: azxo1
  Algorithm for extracting comments from Python source code Pavel1982 7 2,847 Aug-28-2024, 02:50 AM
Last Post: timothyferriss

Forum Jump:

User Panel Messages

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