satwikkansal/wtfpython

Feature request: trying to change the index variable in a for loop

tukkek opened this issue · 2 comments

Hello! After finding a link to your project today on reddit I have decided to give another go at a previous project of mine, now using your document format as inspiration! While doing my research I have come across something that I think would fit well in your list. Here it is:

for i in range(10):
    print(i)
    i = 5             # this will not affect the for-loop
                      # because i will be overwritten with the next
                      # index in the range

This is taken from the Python manual itself, which in itself makes it notable. This might not come as a surprise to anyone who started coding with Python - but for people coming from C++, Java or similar, this is very much something they'd expect to work, giving how for loops work in these languages.

Hope you like this :) Source: https://docs.python.org/3/reference/compound_stmts.html#the-for-statement

By the way, if you have the time to read my own work and maybe let me know if I'm missing anything, I'd be very honored to have you onboard! Here is the link for my current work-in-progress version: https://github.com/tukkek/notablepython/blob/master/README.md

Hey @tukkek, Thanks for your suggestion. I've added the example in the commit ba2238cf . Feel free to suggest corrections (if any).

By the way, if you have the time to read my own work and maybe let me know if I'm missing anything, I'd be very honored to have you onboard! Here is the link for my current work-in-progress version: https://github.com/tukkek/notablepython/blob/master/README.md

Sure, I looked over your project and it seems very interesting. Right now, I'm a bit overwhelmed with response on this project and my ongoing campus placements. But I'll definitely sit back some day, carefully read through your work, and try to contribute to the project :) Thanks again!

Sure thing Satwik, feel free to drop by whenever! You'll be more than welcome!