Dealing cards in a poker game.

for i from 1 to 5: # 5 cards in a hand
    for each player:
        deal a card to the player

And then playing the game is also like a for loop. You loop around the table, giving each player an opportunity to make a bet or fold. But this might be better done using a while loop rather than a for loop.

Answer from Barmar on Stack Exchange
🌐
W3Schools
w3schools.com › js › js_loop_for.asp
W3Schools.com
In the second example, using let, the variable declared in the loop does not redeclare the variable outside the loop.
🌐
W3Schools
w3schools.com › java › java_for_loop.asp
Java For Loop
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop:
Discussions

What is a real-world example of a for-loop? - Computer Science Educators Stack Exchange
A real real world example: for the first 100 visitors who purchase stuff on a site on Black Friday, every item gets 70% discount. ... Save this answer. Show activity on this post. Dealing cards in a poker game. for i from 1 to 5: # 5 cards in a hand for each player: deal a card to the player · And then playing the game is also like a for loop... More on cseducators.stackexchange.com
🌐 cseducators.stackexchange.com
May 28, 2023
Example Do While Loop

Even the preface will be confusing to those that don’t understand the title.

More on reddit.com
🌐 r/shortcuts
9
10
January 26, 2015
What’s a good use of a for loop?
When you know the number of steps beforehand, a for loop is better (more readable). Efficiency isn't in question here, for isn't faster than while or vice versa. More on reddit.com
🌐 r/learnprogramming
8
0
October 29, 2021
Failure to understand a simple for loop might mean I should stop trying to learn?
Nah. Giving up is just about the worst thing you can do. Although, if it takes you 3 hours to understand a for-loop, perhaps take a look at some other tutorials. More on reddit.com
🌐 r/learnprogramming
124
45
May 6, 2020
🌐
Programiz
programiz.com › c-programming › c-for-loop
C for Loop (With Examples)
Before we wrap up, let’s put ... non-negative integer n is the product of all positive integers less than or equal to n. For example, the factorial of 3 is 3 * 2 * 1 = 6....
🌐
University of Utah
users.cs.utah.edu › ~germain › PPS › Topics › for_loops.html
Programming - For Loop
A "For" Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number.
🌐
MathWorks
mathworks.com › matlab › language fundamentals › loops and conditional statements
for - for loop to repeat specified number of times - MATLAB
Suppose that the loop end value is equal to or close to the maximum or minimum value for the loop index data type. In the generated code, the last increment or decrement of the loop index might cause the index variable to overflow. The index overflow might result in an infinite loop.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-for-loops
Python For Loops - GeeksforGeeks
Python continue Statement returns the control to the beginning of the loop. ... # Prints all letters except 'e' and 's' for i in 'geeksforgeeks': if i == 'e' or i == 's': continue print(i)
Published   3 days ago
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-for-loop-with-examples
Java For Loop - GeeksforGeeks
3 days ago - for (initialization; condition; update) { // loop body } ... Initialization is executed once when the loop starts. The condition is evaluated before every iteration. If the condition is true, the loop body executes.
🌐
Berkeley
pythonnumericalmethods.studentorg.berkeley.edu › notebooks › chapter05.01-For-Loops.html
For-Loops — Python Numerical Methods
Alternatively, we could use the item method in a dictionary, and get the key and value at the same time as show in the following example. for key, value in dict_a.items(): print(key, value) ... Note that, we could assign two different looping variables at the same time.
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › for-loop-in-programming
For loop in Programming - GeeksforGeeks
July 23, 2025 - Different programming languages ... of for loops. While the basic functionality remains the same—iterating over a sequence of values or executing a block of code a specified number of times—there are language-specific nuances to be aware of. Let's explore some examples of ...
🌐
W3Schools
w3schools.com › python › python_for_loops.asp
Python For Loops
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, ...
🌐
Go by Example
gobyexample.com › for
Go by Example: For
for is Go’s only looping construct. Here are some basic types of for loops · The most basic type, with a single condition
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Loops_and_iteration
Loops and iteration - JavaScript | MDN
Otherwise, the for loop terminates. (If the condition expression is omitted entirely, the condition is assumed to be true.) The statement executes. To execute multiple statements, use a block statement ({ }) to group those statements. If present, the update expression afterthought is executed. Control returns to Step 2. In the example below, the function contains a for statement that counts the number of selected options in a scrolling list (a <select> element that allows multiple selections).
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-for.html
For Loop
Loop Syntax: the loop begins with the keyword for followed by a variable name to use in the loop, e.g. num in this example. Then the keyword in and a collection of elements for the loop, e.g.
🌐
Programiz
programiz.com › python-programming › for-loop
Python for Loop (With Examples)
Can you solve the following challenge? ... Write a function to calculate the factorial of a number. The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. For example, if n is 5, the return value should be 120 because 1*2*3*4*5 is 120.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › visual-basic › language-reference › statements › for-next-statement
For...Next Statement - Visual Basic | Microsoft Learn
July 15, 2025 - You use a For...Next structure when you want to repeat a set of statements a set number of times. In the following example, the index variable starts with a value of 1 and is incremented with each iteration of the loop, ending after the value of index reaches 5.
🌐
ScholarHat
scholarhat.com › home
Loop in C with Examples: For, While, Do..While Loops
Let’s get into the three types of loops used in C programming. ... A for loop is a control structure that enables a set of instructions to get executed for a specified number of iterations.
Published   July 31, 2025
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › for
for - JavaScript | MDN
These details can be observed by ... point. For example, in this code a closure created within the initialization section does not get updated by re-assignments of i in the afterthought: ... This does not log "0, 1, 2", like what would happen if getI is declared in the loop ...
🌐
Study.com
study.com › courses › computer science courses › computer science 111: programming in c
For Loop in C Programming | Definition, Syntax & Examples - Lesson | Study.com
May 17, 2019 - In this example, finding an incorrect password would result in a true evaluation, and the block in D would run by asking for another password input and increasing the count of attempts by one.
🌐
w3resource
w3resource.com › c-programming-exercises › for-loop › index.php
C programming exercises: For Loop - w3resource
Write a C program to convert a binary number into a decimal number without using array, function and while loop. Test Data : Input a binary number :1010101 Expected Output : The Binary Number : 1010101 The equivalent Decimal Number : 85 Click ...