I have been trying to solve a problem where I am given a list as input and I need to show an output with 7 attached to each string value if it doesn't contain a 7 already.
I have created a list and for the case of 7 not included I have attached the '7' using the for loop. So for example: for the input
["a7", "g", "u"], I expect output as ["a7","g7","u7"] but I am getting the output as follows
['a7', 'g', 'u', ['a77', 'g7', 'u7']]
I have tried to put the values in a new list using append but I am not sure how to remove the old values and replace it with new ones in existing list. Following is my code
class Solution(object):
    def jazz(self, list=[]):
        for i in range(len(list)):
            if '7' not in list[i]:
                li = [i + '7' for i in list]
                list.append(li)
                return list
if __name__ == "__main__":
    p = Solution()
    lt = ['a7', 'g', 'u']
    print(p.jazz(lt))
 
    