text = "hello"
idx = "1"
print(text[idx])TypeError: string indices must be integers, not 'str'
text = "hello"
idx = int("1")
print(text[idx])I passed a string variable as an index without realizing it.
- Related case: https://pyai.io/en/python/basic/strings/