Lesson 12 of 34

for Loops आणि range()

9 min 25 XP

तीच ओळ 100 वेळा लिहू नका! for loop तुम्ही सांगाल तितक्या वेळा काम करतो. range(5) देते 0, 1, 2, 3, 4.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

range(start, stop, step) start पासून सुरू होऊन stop च्या आधी थांबते. step म्हणजे प्रत्येक वेळी किती मिळवायचे.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

for loop एका string च्या प्रत्येक अक्षरातूनही जाऊ शकतो.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

range(1, 11) म्हणजे 1 ते 10. शेवटची संख्या (11) धरली जात नाही!

Challenge

+25 XP

for loop वापरून 1 ते 10 पर्यंत 5 चा पाढा print करा. प्रत्येक ओळ अशी असावी: 5 x 1 = 5

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.