
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Why python for loops don't default to one iteration for single objects?
Python cannot iterate over an object that is not 'iterable'. The 'for' loop construct in python calls inbuilt functions within the iterable data-type which allow it to extract elements from the iterable.
Since non-iterable data-types don't have these methods, there is no way to extract elements from them. And hence for loops ignore them.
- Related Articles
- Why are default values shared between objects in Python?
- Why don't non living things respond to stimulus ?
- Why Don't Transformers Work on DC Supply?
- What is basic syntax of Python for Loops?
- For Loops in Javascript
- Why don't we use the egyptian number system?
- How to use single statement suite with Loops in Python?
- How to use multiple for and while loops together in Python?
- Remove Substrings in One Iteration in python
- Why do the two oceans in Alaska don't mix?
- Feeling Tuned Out? 9 Reasons Why Men Don’t Listen
- Why is using “for…in” loop in JavaScript array iteration a bad idea?
- Why is using “for…in” with array iteration a bad idea in javascript?
- How to iterate over dictionaries using 'for' loops in Python?
- What are the best practices for using loops in Python?

Advertisements