If when you input melt the user gives a number, e.g. 1541, then the variable melt will contain an integer, 1541. However, your listA of elements contains list of 3 items, a string, and 2 integers.
Thus, when you test if melt is in the listA, it doesn't find anything because comparing 1541 to ["scandium", 1541, 2830] will return False as both are not equal.
Moreover, using list to store the elements and their boiling point is not ideal. It is difficult to access for instance the elements boiling point as it is nested in the list. A dictionary implementation, or far better, a dataframe implementation (c.f. pandas) will be much more efficient.
To come back to your code, here is a quick fix:
for w in listA:
if melt == w[1] and boil == w[2]:
print("Is", w[0], "your chosen element?")
Finally, you also have to deal with input error checking to confirm that the user is inputting valid data.
Edit: dictionaries
With dictionary, you can link a key to a value. The key and the value can be anything: number, list, objects, dictionaries. The only condition is that the key must have the hash() method defined.
For instance, you could store the elements with the string as key, and the 2 temperatures as values.
elements = {"scandium": (1541, 2830), "titanium": (1668, 3287)}
To access an elements, you call elements["scandium"] which will return (1541, 2830). You can also access the elements of a dictionary with 3 functions:
elements.keys(): return the keys
elements.values(): return the values
elements.items(): return the tuples (key, value)
However, once again it is not easy to access the temperatures individually. But this time you can compare it this way:
for key, value in elements.items():
if (melt, boil) == value:
print (key)
But even better, since you are looking for the element from the melting and boiling temperature, you can create the following dictionary where the keys are the tuple (boiling, melting) and the value is the corresponding element.
elements = {(1541, 2830): "scandium", (1668, 3287): "titanium"}
Then, once the user inputs melt and boil, you can find the corresponding element with: elements[(melt, boil)]. This time, there is no need to use a loop. The corresponding element can be directly acessed.
A similar implementation can be done with a pandas dataframe.
Finally, you could also implement this using a class.
class Element:
def __init__(self, name, melt, boil):
self.name = name
self.melt = melt
self.boil = boil
elements = [Element("scandium", 1541, 2830), Element("titanium", 1668, 3287)]
As it is, the Element class can not be used as the key of a dictionary. To have it usable as a key, the hash method must be define.
class Element:
def __init__(self, name, melt, boil):
self.name = name
self.melt = melt
self.boil = boil
def __key(self):
return (self.name, self.melt, self.boil)
def __hash__(self):
return hash(self.__key())
But again, it is not that simple to access the element from the melt and boil variables. A loop is again necessary.