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

Python – Checking the number of internal elements in a 3D string list

We are working on counting the number of elements in the 3D string list and using that number.

eleli = [[["ele", "ele", "ele", "ele", "ele"], ["ele", "ele", "ele"]], [["ele", "ele", "ele", "ele", "ele"], ["ele", "ele", "ele", "ele"]], [["ele", "ele", "ele", "ele"], ["ele", "ele", "ele", "ele", "ele"]], [["ele", "ele"]]]

print(len(eleli))

>>>4

Is there a simple way to count all string elements in a 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 :

Yes, there is:

print(sum(len(e) for seq in eleli for e in seq))
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