0
for i in range(5): print(" anything.. ") What does i here depicts??
7 ответов
+ 2
here i depicts a variable which will take a value starting from 1 and will continue till 5
0
please explain more about your problem !
this code is Ok! and it prints 5 times "anything.."
0
i represents the number of values in the list range(5), because range produces a list.
range(5)==[0, 1, 2, 3, 4]
if it were:
poo=['blah', 'fork', 'winslow']
for i in poo:
print('jackalope!')
it would result in:
>>>
jackalope!
jackalope!
jackalope!
0
but...:
poo=['blah', 'fork', 'winslow']
for i in poo:
print(i)
would give you:
>>>
blah
fork
winslow
please correct me if any part of this is wrong.
0
i ranges from 0 to 4 in your problem.. i is nothing but a variable that will take these five values one by one starting with i=0..you could use any variable name in place of i..
0
'i' is used as a counter. Each time the loop completes one round it's value will be increased by a default value of 1. You can give your own value by entering "for I in range(0,5,2)".This will increase the value the value of 'i' by 2 each time. You can also use 'i' within the loop to print members of a list. Hope this helps.
0
Print(range(5))