+ 2
I have a doubt in a code
Recently I saw in a py code a statement like "for _ for _ in range" but I can't find the code Cam someone explain me the meaning
4 Answers
+ 10
'_' can be considered as a variable name.
+ 8
Like @Arsenic said if you use _ in beginning it will become varaible.Maybe your code was like this:
https://code.sololearn.com/ca16A11a24a1
+ 2
Thanks a lot everyone I can't mark anyone best all are the best
+ 1
_ as variable name (instead of i or j or whatever) is sometimes used in loops when you do not need access _.
edit:
Maybe it was some list comprehension?
x = [_ for _ in range(5)]