Questions -
for index in range(20, 10, -3):
print(index, end=' ')
Solution -
range(20, 10, -3): This creates a range of numbers starting from 20, decrementing by 3 at each step, until it reaches a number less than 10. So, the sequence is 20, 17, 14, 11.
for index in range(20, 10, -3):: This is a for loop that iterates over each value in the specified range. In each iteration, the variable index takes on the next value in the range.
print(index, end=' '): This prints the value of index followed by a space. The end=' ' argument is used to specify that a space should be printed at the end of each value instead of the default newline character.
When you run this code, the output will be:
Output : 20 17 14 11
0 Comments:
Post a Comment