Ask coding questions

← Back to all posts
Repl.it process died unexpectedly
MichaelFaulkner (8)

Python code won't run. It says that the repl.it process died unexpectedly. Is this replits fault or mine? https://repl.it/@MichaelFaulkner/Encryption

Answered by heyitsmarcus (282) [earned 5 cycles]
View Answer
Commentshotnewtop
heyitsmarcus (282)

You had just a couple things going wrong with your program:
1) Your while loop has to exit at some point. It was dependent on count not being equal to the length of note. But, count was never modified so the while loop is infinite and breaks Python. A simple fix was adding count += 1 to the next line.
2) Once that was fixed, you had an append command on a string. You only need to append your arrays here. With strings, you would do last_note += i.
3) And then you want the user to see the encoded string, so I put that as a print statement.

I made a fork of your program that you can see here: https://repl.it/@heyitsmarcus/Encryption

print('Welcome to the encryptor.')
menu = input('Would you like to encode or decode a note? ')
letters = [
    "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", ' ']
cyphertext = [
  'K','D','G','F','N','S','L','V','B','W','A','H','E','X','J','M','Q','C','P','Z','R','T','Y','I','U','O', '!', 
  ]
def encode(note):
  new_note = []
  encoded_note = []
  last_note = ''
  count = 0
  while count != len(note):
    new_note.append(note[count].lower())
    count += 1
  print('Encoding note...')
  for i in new_note:
    for letter in letters:
      if i == letter:
        encoded_note.append(cyphertext[letters.index(letter)])
  for i in encoded_note:
    last_note += i
  print(last_note)

print(encode('This is a practice note'))
heyitsmarcus (282)

@heyitsmarcus Please upvote and accept my answer if you think this helped you!