diff --git a/advanced/iters.md b/advanced/iters.md index 58cebbc..cf94927 100644 --- a/advanced/iters.md +++ b/advanced/iters.md @@ -443,6 +443,24 @@ does the same thing as our `count()`. - [The itertools module](https://docs.python.org/3/library/itertools.html) contains many useful iterator-related things. +## Checking if object is itterable or not + +There is an easy way of checking if an object in python is iterable or not. The following code will do the needful. +```python +>>> def check(A): +... try: +... st = iter(A) +... print('yes') +... except: +... print('no') +... +>>> check(25) +no +>>> check([25,35]) +yes +>>> +``` +Here you can observe that the 25 is an integer, so it is not iterable, but [25,35] is a list which is iterable so it outputs no and yes respectively. *** If you have trouble with this tutorial please [tell me about diff --git a/basics/lists-and-tuples.md b/basics/lists-and-tuples.md index 77ea0ca..5f6f342 100644 --- a/basics/lists-and-tuples.md +++ b/basics/lists-and-tuples.md @@ -301,7 +301,7 @@ post about this](http://nedbatchelder.com/blog/201608/lists_vs_tuples.html). item from them. - `thing = another_thing` does not create a copy of `another_thing`. - Tuples are like lists, but they can't be changed in-place. They're - also used in different places. + also used in different places. We can concule by saying that Lists are mutable and Tuples are not. ## Examples