Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Putting Result of Multiplication in a List

I am trying to put a series of multiplications inside a list, I am using the code below:

listx = []
for i in range (2):
    list = [(3*i)]
    listx.append(list)

The problem is that this will put the two results inside two separate lists inside a lists, I just wants the floats to be inside the first list.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

listx = []
for i in range (2):
    listx.append(3*i)

Just use this one. There is no need to create another list for storing the result. You created another list to store the value and appended that list into your listx

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading