Python Math - TypeError: nonetype object is not subscriptable

Python

I'm making a small program for math (no particular reason, just kind of wanted to) and I ran into the error "TypeError: 'NoneType' object is not subscribable.


I have never before seen this error, so I have no idea what it means.

  import math 
  print("The format you should consider:")
  print str("value 1a")+str(" + ")+str("value 2")+str(" = ")+str("value 3a ")+str("value 4")+str("\n") 
  print("Do not include the letters in the input, it automatically adds them")  
  v1 = input("Value 1: ") 
  v2 = input("Value 2: ")
  v3 = input("Value 3: ") 
  v4 = input("Value 4: ")  
  lista = [v1, v3] 
  lista = list.sort(lista) 
  a = lista[1] - lista[0] 
  list = [v2, v4] 
  list = list.sort(list) 
  b = list[1] = list[0] 
  print str(a)+str("a")+str(" = ")+str(b)

The error:

Traceback (most recent call last): File "C:/Users/Nathan/Documents/Python/New thing", line 16, in <module> 

a = lista[1] - lista[0] 

TypeError: 'NoneType' object is not subscriptable

2
Answers

Replies

If you want to know about this topic


Visit: https://360digitmg.com/python-typeerror-nonetype-object-is-not-subsriptable

 


You are using the sort function in the wrong way. Replace the "lista = list.sort(lista)" line with the below line.



liasta = lista.sort()


 

 
 

If you want to unleash your potential in this competitive field, please visit the Python course page for more information, where you can find the Python tutorials and Python frequently asked interview questions and answers as well.

 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.