suppose d is a dict
d={' a ':1,'b ':2}
if we give like this
d.has_key(' a ')
True
but this is false
d.has_key('a')
False
so i tried like this
d.has_key('\sa\s')
False
so how to find dict keys having spaces without stripping their whitespaces
thanks in advance
You will have to remove them:
prints
TrueTo get the value, you can use this method:
This will return just one arbitrary value if
d = {' a ': 1, ' a': 2}andkey = 'a'.