What does ‘str[0]’ do? Why does it print 104 instead of “h”?
104 is the ASCII code of ‘h’.
str[0…0] # → “h”
The range provides start and ending positions. The substring between these
positions (inclusive) is returned. In this case: from position 0 to
position 0.
str[0,1] # → “h”
Here, the first parameter is the starting position. The second the length
of the desired substring.
Could someone explain to me what these do? And why I get:
str[0,0] # → “”
You asked for a substring starting at position 0 of length 0.