how to subdivide the items of a list

Viewed 42

#How do I subdivide each items of a list.

My code

import numpy as np

org_x = [11,15,20,25]
some_list = []
for i in org_x:
    some_list.append(i/2)
print(some_list)

present outcome:

[5.5, 7.5, 10.0, 12.5]

Expected outcome:

[5.5,5.5,7.5,7.5,10.0,10.0,12.5,12.5]
1 Answers

If you want each item twice, you should call append twice at each iteration

for i in org_x:
    some_list.append(i/2)
    some_list.append(i/2)
Related