So I am trying to compare two string variables with == and it is not working for some reason. For example this code
print(dictionary[0])
print("A")
print(dictionary[0] == "A")
prints out
A
A
False
I don't understand why it returns False when they are clearly equal.
Try selecting the output with your cursor - you'll see that first line contains some whitespaces. Basically, your last line is equivalent to:
To get rid of those empty spaces, use str.strip method:
There are also lstrip() and rstrip() methods, removing whitespaces only on the left or right side of the string.