Quantcast
Channel: A different way to check the type of a list - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Guy for A different way to check the type of a list

$
0
0

This is because you are shadowing the built-in list

l = [1,2,3]print(type(l) == list) # True

type(list) gives <class 'list'>, which is not [1,2,3].

You can use one of the options suggested by @ThierryLathuille, but the best practice will be renaming the list variable, you shouldn't use built-in names as variables names.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>