0

Hello. First of all i'm compete newbie in the python. And second i was wondering for some time what does the value 'i" do in python or is it a value at all? I'm sorry if i'm pre-posting a question that have been answered already.

This is the example :


def drawBoard(board):

hline = ' '
for i in range(1, 6):
hline += (' ' * 9) + str(i)

print(hline)
print(' ' + ('0123456789' * 6))
print()

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by vegaseat
0

Sometimes you have to ask 'stupid' questions to get smarter!
We are glad to help.

In your case i is simply the name of a variable that holds the value as you iterate over a given range of numbers. You can use any allowed variable name, I usually use k since it is more visible to my old eyes.

# range(5) will iterate from 0 to 4 (excludes 5)
for k in range(5):
    print(k)

"""my result -->
0
1
2
3
4
"""
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.