Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2016
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cipher Tool Method ?

    Okay, so basically I'm trying to build a tool that will allow users to build ciphers using multiple different methods. I'm kinda stuck on the first one :P

    Anyways:
    I have it set up so that a for function [i] will run in range(in correspondence to the list caeserNumbers). These are then ran through individually and added onto based on variable sv. Basically, the formula for it would be 1 + sv = i. How would I make it so that the max possible value is 26, and then after that it restarts the process at 1 + sv?(I realize the code itself doesn't strictly state 1 + sv, but the for function does that). I've been messing around with this code for about 3 hours and tried the modulo operand but to no avail. I will italicize the specific code pertaining to the post.
    inb4 overloaded with comments; I enjoy having lots of comments for additional readability. If it's a serious problem for anyone I will gladly provide a copy of the code with needless comments taken out
    Code:
    ##-------> userFunctions_DEFINTIONS##
    def Caeser(sv):
        caeserLetters = ['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']
        caeserList = {}
        for ab in range(len(caeserLetters)):
            caeserList[ab] = caeserLetters[ab]
            print(caeserLetters[ab])
        [I]caeserNumbers = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
        caeserList = {}
        for i in range(len(caeserNumbers)):
                cipher = sv + caeserNumbers
                print(i - sv)
                
    #------------------------------------------------------------------------------->#
    
    userFunctions = ["Caeser", "Number Skip", "Skip Letter", "Skip Word", "Cipher Builder"] ##user Commands
    u_f = {} #Command Dump
    for x in range(len(userFunctions)): ##loop through userFunctions
        u_f[x] = userFunctions[x]
    userInput = input("CipherBuild>") ##call for function
    if userInput == u_f[0]:     ###CAESER##
        print("Method Selected: " + str(u_f[0]))
        skipVariable = input("""Please enter your Caeser Skip Number(1-26)
    CipherBuild>""")                                                                                ##input for skip variable
        skipVariableInt = int(skipVariable) #making input readable for math
        Caeser(skipVariableInt) #definition

  2. #2
    New to the CF scene
    Join Date
    Nov 2016
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I see there was a BBCode error in my post in the code. That's fixed here.
    Code:
    ##-------> userFunctions_DEFINTIONS##
    def Caeser(sv):
        caeserLetters = ['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']
        caeserList = {}
        for ab in range(len(caeserLetters)):
            caeserList[ab] = caeserLetters[ab]
            print(caeserLetters[ab])
        caeserNumbers = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
        caeserList = {}
        for i in range(len(caeserNumbers)):
                cipher = sv + caeserNumbers
                print(i - sv)
                
    #------------------------------------------------------------------------------->#
    
    userFunctions = ["Caeser", "Number Skip", "Skip Letter", "Skip Word", "Cipher Builder"] ##user Commands
    u_f = {} #Command Dump
    for x in range(len(userFunctions)): ##loop through userFunctions
        u_f[x] = userFunctions[x]
    userInput = input("CipherBuild>") ##call for function
    if userInput == u_f[0]:     ###CAESER##
        print("Method Selected: " + str(u_f[0]))
        skipVariable = input("""Please enter your Caeser Skip Number(1-26)
    CipherBuild>""")                                                                                ##input for skip variable
        skipVariableInt = int(skipVariable) #making input readable for math
        Caeser(skipVariableInt) #definition

  3. #3
    New Coder
    Join Date
    Nov 2016
    Location
    South Africa, Cape Town
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post
    I never tested this code myself but why not put a conditional statement in the for loop to check that whatever number you have is in the range 0 - 26 and if it's not reset the number.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •