Python For Loop: How to Iterate and Print Numbers
Here is an example of a Python for loop that prints numbers 1 through 10:
for i in range(1, 11):
print(i)
This loop uses the 'range()' function to generate a sequence of numbers from 1 to 10, and then iterates over each number in the sequence using the 'for' keyword. The 'print()' function is called inside the loop to output each number to the console.
原文地址: https://www.cveoy.top/t/topic/mF8s 著作权归作者所有。请勿转载和采集!