Python Forum
looking for for loop thread
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looking for for loop thread
#1
I was gong to write up a for/while loop tutorial because we actually dont have one on here. I was going to link to key points of things that already had a tutorial. I was going to link here for illustration of not using range(len()) and there was another thread somewhere that i cannot find (Written by i think a mod or admin) about for loops. I checked through all the tutorials and could not find it. Maybe it was on another site or maybe is was just a really good response to a questions that never was moved to tutorials.

Anyone remember this? Sorry, I literally had the specific idea of the thread in mind when i started this post, but while writing i drew a blank. Coffee

EDIT:
Too early in the morning without coffee...The thread was comparing about python's for loop looping through a sequence directly as opposed to something like c/c++ for loop increment variable i++ to get through the sequence. It was somewhere in the past month or so.
Recommended Tutorials:
Reply
#2
is it this one you are looking for?
https://python-forum.io/Thread-Basic-Nev...n-sequence
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
That is one I was planning on linking through. But that is not the one I was thinking of
Recommended Tutorials:
Reply
#4
Could probably borrow some stuff from Loop better: A deeper look at iteration in Python.
If look at bottom there like to eg Loop Like A Native.
Also the basic in this video Transforming Code into Beautiful, Idiomatic Python here a Gist with slides(now with f-string could improve also the printing to be more Beautiful).
Reply
#5
Have you done much work on this yet? Because I started a for/while loop tutorial a while back, which has a bout 4k characters in it. I could maybe be persuaded to get off my butt and finish it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#6
Such a tutorial should include at least a short explanation of generators and iterators.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
Thanks snippsat for the links. Will use them.

(Sep-12-2019, 02:31 PM)ichabod801 Wrote: Have you done much work on this yet? Because I started a for/while loop tutorial a while back, which has a bout 4k characters in it. I could maybe be persuaded to get off my butt and finish it.
I have, but i dont see why we cannot have multiple tutorials for the same subject from different people. I think its better to have different perspectives.

I can post it now and soft delete it so you guys can see it. But it is unfinished and short as i just started it this morning. So it is incomplete.

(Sep-12-2019, 02:44 PM)wavic Wrote: Such a tutorial should include at least a short explanation of generators and iterators.
My tutorials tend to skim the basics instead of going into detail of everything. They are not usually for the knowledge hungry, but to use as a reference to look through. I wonder if these could be a separate tutorial?
Recommended Tutorials:
Reply
#8
(Sep-12-2019, 03:55 PM)metulburr Wrote: I wonder if these could be a separate tutorial?
They could be,but as basic overview may not need to dig to deep in as it could clutter stuff up.
Could refers to eg Trey's Loop better if someone would have deeper look into it.
Reply
#9
Im done for today. By the time i got sick of writing it out i didnt have time to implement your links. But i linked them as they were good for more info. Take a scan on it for missing or incorrect material. I didnt even get to a while loop so i just named it for loops.
Recommended Tutorials:
Reply
#10
Look okay at a quick glance Thumbs Up
In list comprehensions,could add this.
# Ordinary loop with append to new list
lst = ['spam', 'ham', 'eggs', 'ham']
ham_lst = []
for item in lst:
    if item == 'ham':
        ham_lst.append(item)
print(ham_lst)

# With list lomprehensions code over become this
ham_lst = [item for item in lst if item == 'ham']
print(ham_lst)

# Both create a new list "ham_lst".
# So problems that can occur if modify the original list in the loop sequence,will not affect when create a new list 
The last links is better to give title in link than the raw url.
Example:
Loop better: A deeper look at iteration in Python
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Just Practicing Posting. Test Thread. “Sandbox” Thread. No Reply needed, Thanks Doc_AElstein 4 6,146 Dec-21-2017, 08:55 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020