Question: Please solve in Python using one-line list comprehension Write a function that takes a list of strings and encodes each string by shifting left based
Please solve in Python using one-line list comprehension
Write a function that takes a list of strings and encodes each string by shifting left based on the string's index. Assume that strings are never empty.
Example: if input is ['123', '123', '123'], then output should be [ '123', '231', '312'] ; that is because '123' is at index 0, it doesn't shift; '123' is at index 1, so it shifts once leftwards, '123' is at index 2, it shifts left twice.
def encoding(message): """ >>> encoding(['123', '123', '123']) ['123', '231', '312']
>>> encoding(['25', '25', '25', '25']) ['25', '52', '25', '52']
>>> encoding(['123', '1', '567', '8']) ['123', '1', '756', '8'] """
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
