Skip to content

Commit 24c4a64

Browse files
committed
Minor exmpample: Correct explanation
* `'a'[0][0][0][0][0]` is semanically correctly not because strings are iterables but because they are sequences as well. Related to satwikkansal#30
1 parent 5467a67 commit 24c4a64

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ a, b = a[b] = {}, 5
16301630

16311631
* Few weird looking but semantically correct statements:
16321632
+ `[] = ()` is a semantically correct statement (unpacking an empty `tuple` into an empty `list`)
1633-
+ `'a'[0][0][0][0][0]` is also a semantically correct statement as strings are iterable in Python.
1633+
+ `'a'[0][0][0][0][0]` is also a semantically correct statement as strings are [sequences](https://docs.python.org/3/glossary.html#term-sequence)(iterables supporting element access using integer indices) in Python.
16341634
+ `3 --0-- 5 == 8` and `--5 == 5` are both semantically correct statements and evaluate to `True`.
16351635

16361636
* Given that `a` is a number, `++a` and `--a` are both valid Python statements, but don't behave the same way as compared with similar statements in languages like C, C++ or Java.

0 commit comments

Comments
 (0)