This is what I am doing,
amount = [2, 2, 3]
my_list = ['name_zero', 'name_one', 'score_three', 'score_nine', 'age_zero', 'age_ten', 'age_six']
output = []
for i in amount:
output.append(my_list[:i])
print(output)
what I am getting:
[['name_zero', 'name_one'], ['name_zero', 'name_one'], ['name_zero', 'name_one', 'score_three']]
The problem with my code is, It is appending the same elements, what should be the right approach to receive output like this?
# [['name_zero', 'name_one'], ['score_three', 'score_nine'], ['age_zero', 'age_ten', 'age_six']]