Skip to content

Commit

Permalink
Adding solution in episode 02
Browse files Browse the repository at this point in the history
  • Loading branch information
wood-chris committed Feb 24, 2024
1 parent fef55d8 commit dc7b92f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _episodes/02-short-introduction-to-Python.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ a_list = [1, 2, 3]
> 4. What information does the built-in function `len()` provide?
Does it provide the same information on both tuples and lists?
Does the `help()` function confirm this?
>
> > ## Solution
> > ~~~
> > 1. The second value in a_list is replaced with 5.
> > 2. There is an error: TypeError: 'tuple' object does not support item assignment; As a tuple is immutable, it does not support item assignment. Elements in a list can be altered individually.
> > 3. `<class 'tuple'>`; The function tells you that the variable *a_tuple* is an object of the class *tuple*.
> > 4. len() tells us the length of an object. It works the same for both lists and tuples, providing us with the number of entries in each case.
> > ~~~
> {: .solution}
{: .challenge}
Expand Down

0 comments on commit dc7b92f

Please sign in to comment.