So, I'm self teaching programming for the first time and I decided to start with Python! I'm learning about strings and lists. I know strings are immutable and lists are mutable. My doubt comes from the fact that:
>>> s = "hello"
>>> s[5]
returns "IndexError: string index out of range" OK I get it cause strings as I said are immutable and s only has 5 elements (from index 0 to 4).
But if I issue:
>>> s[0:1000]
I get:
'hello'
I understand that if I issue the same command on a list it will return every element because lists are mutable and I can re-assign values but How come no errors appear with strings? Indexes 5 to 1000 don't exist.
Thank you!!!