Often times we want to create a list containing a continuous value like, in a range of 100-200. Let’s discuss how to create a list using the
Will this work ?
As we can see in the output, the result is not exactly what we were expecting because Python does not unpack the result of the range() function.
Code #1: We can use argument-unpacking operator i.e. *.
As we can see in the output, the argument-unpacking operator has successfully unpacked the result of the range function.
Code #2 : We can use the
extend() function to unpack the result of range function.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.