OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

TypeError: 'type' object is not subscriptable Python

  • Thread starter Thread starter Sebastian
  • Start date Start date
S

Sebastian

Guest
Whenever I try to type-hint a list of strings, such as

Code:
tricks: list[str] = []

, I get TypeError: 'type' object is not subscriptable. I follow a course where they use the same code, but it works for them. So I guess the problem is one of these differences between my an the courses environments. I use:

  • vs code
  • anaconda
  • python 3.8.15
  • jupyter notebook

Can someone help me fix that?

I used the same code in normal .py files and it sill doesn't work, so that is probably not it. The python version should also not be the problem as this is kind of basic. Anaconda should also not cause such Error messages. Leaves the difference between vscode and pycharm, which is also strange. Therefore I don't know what to try.
<p>Whenever I try to type-hint a list of strings, such as</p>
<pre><code>tricks: list[str] = []
</code></pre>
<p>, I get <em>TypeError: 'type' object is not subscriptable</em>. I follow a course where they use the same code, but it works for them. So I guess the problem is one of these differences between my an the courses environments. I use:</p>
<ul>
<li>vs code</li>
<li>anaconda</li>
<li>python 3.8.15</li>
<li>jupyter notebook</li>
</ul>
<p>Can someone help me fix that?</p>
<p>I used the same code in normal .py files and it sill doesn't work, so that is probably not it.
The python version should also not be the problem as this is kind of basic.
Anaconda should also not cause such Error messages.
Leaves the difference between vscode and pycharm, which is also strange.
Therefore I don't know what to try.</p>
 

Latest posts

Top