Try to search your question here, if you can't find : Ask Any Question Now ?

Activate code when loop reaches a certain number

HomeCategory: stackoverflowActivate code when loop reaches a certain number
Avatarjohn asked 3 months ago

I need to know how to run code when the for loop reaches a certain number. The loop currently runs

card_a(stack1_xpos, stack1_ypos)

the number of times found in the third value of the list shown below (It is 9 in this example)

['Stack 1', 'Suit A', 9, 6]

My current function is:

def deal_cards(game):
for (idx, stack) in enumerate(game):         
    if stack[0] == 'Stack 1':                       
        if stack[1] == 'Suit A':                    
            for i in range(stack[2]):                                 
                card_a(stack1_xpos, stack1_ypos)

I want it so that when the loop reaches the same number as the 4th item in the list (6 in this example) it will run the code:

card_e(stack1_xpos, stack1_ypos)

And then return back to running

card_a(stack1_xpos, stack1_ypos)

for the rest of the loop.

How could I do this?

1 Answers
Best Answer
AvatarArben answered 3 months ago
Your Answer

12 + 7 =

Popular Tags

WP Facebook Auto Publish Powered By :