true division always returns float, so
also don't use str as variable name . it's a type and you overshadow it, i.e. you will not be able ti use it if needed
length / 2
returns float which is not allowed as index. use floor division length // 2
also don't use str as variable name . it's a type and you overshadow it, i.e. you will not be able ti use it if needed
my_str = 'foo' print(isinstance(my_str, str)) str = 'bar' print(isinstance(my_str, str))
Output:True <-- this is first print
Traceback (most recent call last):
File "************", line 4, in <module>
print(isinstance(my_str, str))
TypeError: isinstance() arg 2 must be a type or tuple of types
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs