The Coding Studio Inc. Tips
Enumerate and Zip in Python
Published: 2024-01-03
The built-in 'enumerate' function in Python allows us to iterate over a sequence such as a list, tuple, or string and it also keeps track of the current index of the current item. Python countries = ['USA', 'UK', 'Canada', 'Australia'] for index, country in enumerate(countries): print(f"Index: {index}, Country: {country}") Index: 0, Country: USA Index: 1, Country: UK Index: 2, Country: Canada Index: 3, Country: Australia