. . . . and ... . . . . .
InBetween : There are over 100 issues in between the release of James Bond in Oct. 2001 and its planned release in Nov. 2006.
Q:
Cannot find the cause of error in comparing the elements of a list of lists
I am trying to find the cause of the error in the following program. The program keeps throwing a IndexError: list index out of range exception on the line comparing the two lists of integers and returns True if they are equal and returns False if they are not.
I understand that the program may not be the best way to do this but i am a beginner in Python and for my needs this is very good.
I have read that it is a problem of comparing the empty lists for elements.
Thanks in advance.
def equal(a, b):
if a == b:
return True
if not a and not b:
return False
lista = [1,2,3,4,5]
listb = [2,3,4,5,6]
print(equal(lista,listb))
A:
You need to change the syntax of your if statements. For example:
if a == b:
# Do something
should be changed to
and
if not a and not b:
if not a:
because if a is False then it would be the same as not a. In your code, you are checking if a is None, which is not the same as if it is False (which is a list of None, [None, None, None, None, None]).
The present invention relates to a gas detector for detecting gas. The invention has particular application in the detection of gas leaks at a hydrocarbon processing facility.
It is known to provide a gas detector at a hydrocarbon processing facility to detect the presence of gases leaking from the facility. For example, a gas detector may be installed to detect the presence of hydrogen gas leaking from a hydrogenation reactor at a hydrocarbon processing facility. If
Related links:
留言