Advertisement
Radismela

Messaging / More Exercises: Lists Basics

Jun 16th, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. cipher = input().split()
  2. message = list(input())
  3.  
  4. decoded_message = []
  5.  
  6. for symbol in cipher:
  7.     start_cipher = 0
  8.     current_symbol = 0
  9.     current_cipher = list(symbol)
  10.     for num_cipher in range(start_cipher, len(current_cipher)):
  11.         current_symbol += int(current_cipher[num_cipher])
  12.     start_cipher += 1
  13.     if len(message) < current_symbol:
  14.         index = current_symbol - len(message)  # ако цифрата е по-голяма от стринга, стига до края и започва да брои отначало
  15.     else:
  16.         index = current_symbol
  17.     decoded_message.append(message[index])
  18.     message.pop(index)
  19.  
  20. print("".join(decoded_message))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement