+ 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

2nd Jan 2021, 8:24 AM
Perplexed Coder
Perplexed Coder - avatar
4 Answers
+ 10
'_' can be considered as a variable name.
2nd Jan 2021, 8:32 AM
Arsenic
Arsenic - avatar
+ 8
Like @Arsenic said if you use _ in beginning it will become varaible.Maybe your code was like this: https://code.sololearn.com/ca16A11a24a1
2nd Jan 2021, 8:56 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Thanks a lot everyone I can't mark anyone best all are the best
2nd Jan 2021, 2:28 PM
Perplexed Coder
Perplexed Coder - avatar
+ 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)]
2nd Jan 2021, 9:34 AM
Lisa
Lisa - avatar