Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Simple For Loops | For Loops
Python Loops
course content

Зміст курсу

Python Loops

Python Loops

1. While Loops: Get Started
2. While Loops: Essentials
3. For Loops
4. Nested Loops

Simple For Loops

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Завдання

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Завдання

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 1
toggle bottom row

Simple For Loops

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Завдання

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Завдання

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 1
toggle bottom row

Simple For Loops

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Завдання

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Завдання

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Finally, more interesting Python loops! There is another type of loops with the following syntax:

12
for val in list: instructions
copy

val receives the current value from list on each iteration. This way, you don't need any stop condition in your loop and it never becomes infinite. Use for loop for any iterable object: list, tuple, string, etc.

By the way, it is much more appropriate to iterate string using for loop instead of while.

123
string = 'You are rockstar' for sym in string: print(sym * 13)
copy

Завдання

Change the given word by skipping all spaces, like:

And I don't wanna miss a thing -> AndIdon'twannamissathing

Use for loop. Create new_word for that, modify it inside the loop and output it.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 1
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt