Is it possible to do following without the i?
for i in range(some_number):
# do something
If you just want to do something N amount of times and don’t need the iterator.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Off the top of my head, no.
I think the best you could do is something like this:
But I think you can just live with the extra
ivariable.Here is the option to use the
_variable, which in reality, is just another variable.Note that
_is assigned the last result that returned in an interactive python session:For this reason, I would not use it in this manner. I am unaware of any idiom as mentioned by Ryan. It can mess up your interpreter.
And according to Python grammar, it is an acceptable variable name: