So I recently came to know about the asterisk function in Python which is used to unpack the values. I tried to implement it in my code for the given question below. But unfortunately, I am getting this error:
Traceback (most recent call last):
File "tests.py", line 1, in <module>
from solution import *
File "/workspace/default/solution.py", line 2
return *[x[1:]+x[0]+'ay' for x in text.split()]
^
SyntaxError: can't use starred expression here
Q.Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched.
Examples
pig_it('Pig latin is cool') # igPay atinlay siay oolcay
pig_it('Hello world !') # elloHay orldway !
My Code:
def pig_it(text):
return *[x[1:]+x[0]+'ay' for x in text.split()]