Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
an extra step in a loop
#1
i am iterating over something with a loop such as for x in thing: but there is sometimes a value in x which needs an extra step. on example of that is stepping through the characters of a string and getting a backslash to perform some special action based on the next character then moving on in the loop. what if this is invoking a yield statement?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
for x in thing:
posted too quick, hold on...

    for x in thing:
        if special_step == True:
            special step
            special_step = False

        if x == "/":
           special_step = True
        else:
           normal step
????? maybe?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  An Extra 'None' leoahum 5 3,821 Oct-18-2018, 08:20 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

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