python finds an error in the list when it runs when writing code
Code:
n=input("") RESULT[n]='"' + RESULT[n] + '"' print(RESULT[n])
Error: TypeError: list indices must be integers or slices, not str
The translation of the error means: TypeError: list index must be an integer or slice, not str
This is saying that the index target cannot be a character, which means that n in RESULT[n] is a string, not an integer
When my mouse moves to n there
Sure enough, n is a string type, because the list index must be an integer or a slice, this string designation is to report an error
Variables are entered with consideration for where they will be used! ! !
Just change it:
n=int(input("")) RESULT[n]='"' + RESULT[n] + '"' print(RESULT[n])