๐Ÿ”‚ For In

The ๐Ÿ”‚ statement allows you to quickly iterate over an instance, that is repeatedly retrieving values from it until there are no more values to provide.

For example, you can iterate over an ๐Ÿจ instance and youโ€™ll receive all elements contained in the list.

Syntax

๐Ÿ ๐Ÿ‡
๐Ÿฟ ๐Ÿ”คcookies๐Ÿ”ค ๐Ÿ”คmilk๐Ÿ”ค ๐Ÿ”คeggs๐Ÿ”ค ๐Ÿ”คblueberries๐Ÿ”ค ๐Ÿ† โžก๏ธ grocery
๐Ÿ”‚ item grocery ๐Ÿ‡
๐Ÿ˜€ itemโ—๏ธ
๐Ÿ‰
๐Ÿ‰

The output would be:

cookies
milk
eggs
blueberries

In this example, the code block will be repeated for every value of the list and the values are printed. The type of item is naturally ๐Ÿ”ก.

Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Emojicode on Codecademy

Edit this page on GitHub

Contributors