my_string = test
def func_2(my_string):
return [i+"*" for i in my_string if i!=my_string[len(my_string) - 1] else i]
print(func_2(my_string.copy()))
In the above code snippet, I need to use list comprehension to append the characters of my name with a ''. For example, in the above example, the expected result is test
But, I am getting "invalid syntax" as the error. Any insights on this would be greatly appreciated. Thanks