From d06fcbff1bd456029bf5e91993cab80bc93abe37 Mon Sep 17 00:00:00 2001 From: Vitor Santa Rosa Date: Sat, 28 Nov 2020 23:25:16 -0300 Subject: [PATCH] Improve string indexing result explanation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7137d07..2459735 100644 --- a/README.md +++ b/README.md @@ -3554,7 +3554,7 @@ What makes those dictionaries become bloated? And why are newly created objects * Few weird looking but semantically correct statements: + `[] = ()` is a semantically correct statement (unpacking an empty `tuple` into an empty `list`) - + `'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. + + `'a'[0][0][0][0][0]` is also semantically correct, because Python doesn't have a character data type like other languages branched from C. So selecting a single character from a string returns a single-character string. + `3 --0-- 5 == 8` and `--5 == 5` are both semantically correct statements and evaluate to `True`. * 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.