i would like to append an item into list_b only if it is one above '5H' which is '6H'
list_a = ('2A','4A','8H','6H')
list_b = ['5H']
list_a.pop() gives a '6H'
therefore if i append the '6H' it should be able to be added to list_b since its just one above '5H'.
i tried to compare the first values but it gives an error because the 1 in the code below is an int and list_b[-1][0] is a str.
if list_b[-1][0] + 1 != list_a.pop()[0]:
print('Error')
Therefore i cannot use list_b[-1][0] + 1
Presuming that
list_areally is a list, not a tuple, otherwiselist_a.pop()won’t work …You need to do TWO things:
(1) convert the first characters to
intso that you can compare them properly(2) check that the second characters are the same … from your problem description, it would appear that
'6G'and'6I'(amongst many others) are not OK