Ainsteinx Logo
Ainsteinx
👤
Welcome to Ainsteinx
Login

Change Language

Currency

Home
Blog
Services
All lessons
EP.4 Python for Laos

for loops: repeat without retyping

for i in range(1, 6):
    print("ຮອບທີ", i)
Video coming soon
EP.4 Basics

for loops: repeat without retyping

Count from 1 to 5 with a single line of logic.

for repeats work many times. range(1, 6) gives the numbers 1, 2, 3, 4, 5 (6 is not included).

On each pass, the variable i becomes the next number.

ep04-for-loop.py
for i in range(1, 6):
    print("ຮອບທີ", i)

Output

ຮອບທີ 1
ຮອບທີ 2
ຮອບທີ 3
ຮອບທີ 4
ຮອບທີ 5
  • #PythonສຳລັບຄົນLaos
  • #Python
  • #ຮຽນໂປຣແກຣມ
  • #ບອກຕໍ່ຄວາມຮູ້
  • #shorts

Watch and share on