0
What's the use of _ in python?
I often see for loop written as for _ in range(5): instead of for i in range(5): What's the difference and what are some other uses of '_'? Thanks '_'
7 odpowiedzi
+ 1
fascinating/interesting...:
for _ in range(10):
print(_ * 2)
I was aware of using the "_" for tuple/list unpacking. e.g:-
a, _, _, _, b = (10, 11, 12, 13, 14)
print(a, b)
#or
c, *_, d = (10, 11, 12, 13, 14)
print(c, d)
0
Mirielle👽 Could you explain your second point with an example?
0
Mirielle👽 Then what is with '__init__' there we use '_' as well, don't we?
0
rodwynnejones pretty interesting! thanks for sharing