In Python, which loop is used to iterate over a sequence of elements?
- else
- for
- if
- while
In Python, a for
loop is used to iterate over a sequence of elements, such as a list, tuple, or string. It allows you to perform a set of operations for each item in the sequence.
Loading...
Related Quiz
- What is the result of the operation True or False and True?
- How can you implement a switch-case like behavior in Python?
- You have identified a performance issue in a critical section of your Python code. Which Python profiling tool would you use to analyze the execution time of this code section and identify the bottleneck?
- If a class has the slots attribute defined, it means the instances of that class will not have a _______ dictionary.
- You are implementing a caching mechanism. You need a data structure that removes the least recently added item when the size limit is reached. Which built-in Python data structure would you use?