Advertisement
makispaiktis

ReversedAtbas

Jul 13th, 2019 (edited)
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. import math
  2.  
  3. alphabet = "abcdefghijklmnopqrstuvwxyz"
  4. print()
  5. print("Enter a message  below to cipher it: ")
  6. message = input("Message here: ")
  7.  
  8. # CONVERT my message = STRING ----> LIST
  9. messageList = []
  10. for i in range(len(message)):
  11.     messageList.append(message[i])
  12.  
  13. print(messageList)
  14.  
  15. # Copy messageList to initialMessageList
  16. initialMessageList = messageList.copy()
  17. # I will work with messageList to make the changes to my messsage
  18. # 1st step: REVERSE MY LIST
  19. for i in range(int(len(messageList)/2)):                                    # Scan the half list and reverse it
  20.     temp = messageList[i]                                                   # Swap method for elements in list
  21.     messageList[i] = messageList[len(messageList) - 1 - i]
  22.     messageList[len(messageList) - 1 - i] = temp
  23.     # OR: messageList.reverse()
  24.  
  25. reversedList = messageList.copy()                   # I keep the reversed messageList in the variable reversedList
  26. print(reversedList)
  27.  
  28. # 2nd step: ATBAS SESSION
  29. # I will create another list to add the elements that I have from Atbas Code
  30. atbasList = []
  31. for ch in messageList:                              # ch = a character from the messageList
  32.     for i in range(len(alphabet)):                  # I scan the alphabet in order to find my "ch" character
  33.         if ch == alphabet[i]:
  34.             atbasList.append(alphabet[len(alphabet) - 1 - i])       # In case of equality ----> I add in atbasList the appropriate letter
  35.             break
  36.  
  37. print(atbasList)
  38.  
  39. '''
  40. My Lists now:
  41. 1) initialMessageList: Contains the letters of the given word
  42. 2) reversedList: Contains the letters of the given word, but in reversed form
  43. 3) atbasList: Contains the letters of the given word, in BUT REVERSED and ATBAS-ED form
  44. '''
  45.  
  46. print()
  47. print("Message first: " + ''.join(map(str, initialMessageList)))
  48. print("Message after: " + ''.join(map(str, atbasList)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement