title: Substitution Cipher Python
body: <p>I have to make a Substitution Cipher Program, where I first create a randomized secret-key and then use this key to decrypt/ encrypt some user input (plaintext). The constraints for the problem as follows: </p>
  
  <ol>
  <li><p>encryptMsg(plaintext,key,alphabet)
  Takes a plaintext string, an alphabet string and a secret key string as arguments and returns an
  encrypted cipher string. Note, within this function, you must first convert the plaintext string to all
  lower case and remove any punctuation/characters that do not appear in the alphabet string!</p></li>
  <li><p>decryptMsg(ciphertext,key,alphabet)
  Will take a ciphertext string, an alphabet string and a secret key string and return the plaintext
  string.</p></li>
  <li><p>makeKey(alphabet)
  Generate and return a secret-key string by randomly shuffling the characters in the alphabet string
  argument. Hint: this involves turning the string into a list, using the random.shuffle()
  method, then turning the list back into a string </p></li>
  </ol>
  
  <p>Here's what I have: </p>
  
  <pre><code>import random
  alphabet = "'abcdefghijklmnopqrstuvwxyz.,!'"
  
  def makeKey(alphabet):
     alphabet= list(alphabet)
     key= random.shuffle(alphabet)
     alphabet= str(alphabet)
     return key
  
  
  def encrypt(plaintext, key, alphabet):
      """Encrypt the string and return the ciphertext"""
      return ''.join(key[l] for l in plaintext)
  print (alphabet)
  </code></pre>
  
  <p>I know I'm doing something wrong with the makeKey function because it doesn't work. I need some help on how to start the other functions. We cannot use dictionaries, only list methods. Any help or just advice on jumpstarting me in my assignment will be highly appreciated. Thanks guys!</p>
  
  <p>UPDATE: A sample output is as follows:</p>
  
  <p>Alphabet: 'abcdefghijklmnopqrstuvwxyz.,! '</p>
  
  <p>Key: 'nu.t!iyvxqfl,bcjrodhkaew spzgm'</p>
  
  <p>Input plaintext: Hey, this is really fun!</p>
  
  <p>Cipher text: 'v! zmhvxdmxdmo!nll mikbg'</p>
  
  <p>Decrypted text: 'hey, this is really fun!' </p>