I have a data structure like this
[[1,2,3,4,5], {9,2,5,8,7}, (7, 4, 8, 6)]
One big list containing lists, sets, and tuples.
I want to multiply everything inside a list by 3, but not the things inside tuple or set. Output should be:
[[3,6,9,12,15], {9,2,5,8,7}, (7, 4, 8, 6)]
The items inside the list all got multiplied by 3, rest remain unchanged.
I have tried this:
l = [[2,6,9,13,15], {9,2,5,8,7}, (7, 4, 8, 6)]
newList = [[subitem*3 for subitem in subList ] for subList in l]
print(newList)
But this gives me bad output:
[[3, 6, 9, 12, 15], [24, 27, 6, 15, 21], [21, 12, 24, 18]]
The list is good, but the set and tuple need to remain unchanged, they shouldn't be converted to list either. I want output exactly like I have shown previously.
Thanks!