Advertisement
PowerCell46

Decipher This! Python

Jan 1st, 2023
1,427
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. list_of_decripted_words = (str(input())).split()
  2. print_result = ""
  3.  
  4. for index in range(0, len(list_of_decripted_words)):
  5.     current_decrypted_word = (list_of_decripted_words[index])
  6.     current_decrypted_word_list = []
  7.     for letter in current_decrypted_word:
  8.         current_decrypted_word_list.append(letter)
  9.     first_digit = current_decrypted_word_list.pop(0)
  10.     second_digit = current_decrypted_word_list.pop(0)
  11.     digits = first_digit + "" + second_digit
  12.     if current_decrypted_word_list[0] == "1" or current_decrypted_word_list[0] == "2" or  current_decrypted_word_list[0] == "3" or current_decrypted_word_list[0] == "4" or current_decrypted_word_list[0] == "5" or current_decrypted_word_list[0] == "6" or current_decrypted_word_list[0] == "7" or current_decrypted_word_list[0] == "8" or current_decrypted_word_list[0] == "9" or current_decrypted_word_list[0] == "0":
  13.         third_digit = current_decrypted_word_list.pop(0)
  14.         digits += third_digit
  15.  
  16.     first_letter = chr(int(digits))
  17.     if len(current_decrypted_word_list) > 1:
  18.         second_letter = current_decrypted_word_list.pop(0)
  19.         last_letter = current_decrypted_word_list.pop()
  20.         current_decrypted_word_list.insert(0, last_letter)
  21.         current_decrypted_word_list.append(second_letter)
  22.     current_decrypted_word_list.insert(0, first_letter)
  23.  
  24.     print_result+= ("".join(current_decrypted_word_list) + " ")
  25.  
  26. print(print_result)
  27.  
  28.  
Advertisement
Comments
  • Jump_off_a_cliff
    1 year (edited)
    # text 1.21 KB | 1 0
    1. Your script appears to be designed to decrypt a list of words that have been encrypted in a specific way. Here's a breakdown of what the code does:
    2.  
    3. 1. Accepts a string of input from the user and ssplits it into a list of words.
    4. 2. Initializes an empty string called 'print_result'
    5. 3. Iterates over each word in the list of decrypted words.
    6. 4. For each word, converts it into a list of letters
    7. 5. Removes the first two letters of the list and stores them as a string called 'digits'.
    8. 6. If the first letter of the list is a digit, removes that letter as well and adds it to 'digits'.
    9. 7. Converts 'digits' into a character by using the 'chr()' function and storing it in a variable called 'first_letter'.
    10. 8. If the list of letters has more than 1 element, removes the second letter and the last letter, and reorders the list so that the last letter is the first element and the second letter is the last element.
    11. 9. Inserts 'first_letter' at the beginning of the lsit of letters.
    12. 10. Joins the list of letters into a single string and adds it to 'print_result', followed by a space character.
    13. 11. After all the words have been processed, prints 'print_result'.
    14.  
    15. I haven't really decrypted the code however, helping others.
    • PowerCell46
      1 year
      # text 0.19 KB | 0 0
      1. You are absolutely correct. I am just pasting the solution of a task that I've done for my university, which is named Desipher this! I didn't mean for anyone to actually try and desipher it. :)
Add Comment
Please, Sign In to add comment
Advertisement