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

Why does the length of the elements in the list shrink?

My test code:

num = ['a',
       'b',
       'c',
       'd',
       'e'
       'f']
num_len = len(num)
print(num_len)

The output is 5, but I think it should be 6, why?

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 :

As well as what other people have answers, print the list so you can see what Python sees in the list:

>>> print(num)
['a', 'b', 'c', 'd', 'ef']

then you can see where the problem is.

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