Home > other >  When in use the list () function to generate an empty list
When in use the list () function to generate an empty list

Time:01-13

Use the list () function to convert the object to the list, USES 2 times in a row on the same object list (after), second list () to generate the empty list,

Pictured above, f list became the empty list,

Originally found when using zip () function,


CodePudding user response:

Range zip enumerate generated is iterator object, such as they are all one-time after traversal ends, unlike fixed container list a tuple can traverse many times, so when you first use the list (e), e traverse cannot, it is [] g
To test the e when there are elements within, you can print (next) (e) look at it

CodePudding user response:

Zip () function has been explained,
After x in python3., zip () returns the generator, can only single traversal, so the second g=list (e), g is empty,
In previous versions of the zip () returns the tuple, can be repeated traversal,
With the old version of PYTHON you try to see,
  • Related