I have a problem with comparing 2 list indexes.
In code
inventory=['q', 'w', 'e', 'r']
print(inventory)
if 'q' and 'w' in inventory:
a=inventory.index('q')
b=inventory.index('w')
else:
print('\nNothing')
if a > b:
a+=1
del inventory[:a]
print("Your inventory:")
print(inventory)
print(a)
elif b<a:
b+=1
del inventory[:b]
print("Your inventory:")
print(inventory)
print(b)
else:
print('Sth went wrong')
print(a,b)
a
b
['q', 'w', 'e', 'r']
Sth went wrong
0 1
In your if
statement you have
if a > b:
...
elif b < a:
...
These are the same thing. The second condition should be b > a: