0
Why do we need an empty string. Still confuses me (solved)
def num_list(): num ="" for n in "3445": num += n yield num print(list(num_list())) output : ['3', '34', '344', '3445']
3 Réponses
+ 3
Because num=""
we are defining the data type for num
means num data type is a string not a number
string + string = stringstring
in our example
"3" + "4" = 34
+ 1
Arinda Mark Alvin
Think of it as an empty container.
You can write code which will choose what goes into the container, so the end result will be a collection of items of your choice.
0
Ohh okay. Thanks