I have this dictionary:
a = {
'car1': ('high cp', 'low fd', 'safe'),
'car2': ('med cp', 'med fd', 'safe'),
'car3': ('low cp', 'high fd', 'safe'),
'taxi1': ('high cp', 'low fd', 'safe', 'med wt'),
'taxi2': ('high cp', 'low fd', 'safe', 'high wt'),
'taxi3': ('high cp', 'low fd', 'safe', 'high wt')
}
From the above dictionary, I want to create a new dictionary that consists only 'car%s'
I'm using this code snippet (from another question)
b = {}
for key in a:
if key == 'car%s'% (range (4)):
print (" %s : %s" % (key, a[key]))
print(b)
It returns {}
I expect to get:
a = {
'car1': ('high cp', 'low fd', 'safe'),
'car2': ('med cp', 'med fd', 'safe'),
'car3': ('low cp', 'high fd', 'safe'),
}
What am I missing here?