Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. #!/bin/python
  2. import sys
  3.  
  4.  
  5.  
  6. def stringintolist(str):  # taking the string argument and making it a list
  7.     cipherchar = []       # make an empty list
  8.     cipherchar = list(str) # taking each letter
  9.     return cipherchar      # this function then spits out the list
  10.    
  11.  
  12. def CheckForCoincidences(str):  # This function takes a string, creates the first test string, and letter by letter compares side by side
  13.                 # This is the counter for how many times on that line the letter is the same
  14.     filler = '0'                # This is a filler character to add to the front of the list, moving the list over
  15.     CipherText = stringintolist(str) # Calling the list of letters CipherText for ease
  16.     TestText = []                    # creating empty TestText list
  17.     for i in CipherText:            # putting each letter from CipherText into TextText
  18.         TestText.append(i)
  19.     TestText.insert(0,filler)    # adding the first filler to get started
  20.  
  21.     #start to compare here.
  22.     for i in range(len(CipherText)):
  23.         SameLetter = 0                        # Set the same letter counter to 0 after each TestText change (each 'line')
  24.         for i, j in zip(CipherText,TestText): # testing a character in that line
  25.             if i == j:                         # if it's the same...
  26.                 SameLetter += 1                   # add 1 to our same letter counter
  27.         print SameLetter
  28.         TestText.insert(0,filler)              # now that we are done doing the first line, change it to be the second one.
  29.  
  30.        
  31. CheckForCoincidences(sys.argv[1])  # running the defs.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement