Here's an example of a Python for loop:

# print the numbers from 1 to 10
for i in range(1, 11):
    print(i)

This for loop uses the built-in range() function to generate a sequence of numbers from 1 to 10. The loop variable i takes on each value in the sequence, and the print() function is called with i as an argument to output each number to the console.

Python For Loop: A Beginner's Guide with Example

原文地址: https://www.cveoy.top/t/topic/mF7l 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录