I am a string substitute that takes a few vaules and was wondering is it possible to skip a key and leave it there, not filling it with a space?
s='%(name)s has a %(animal)s that is %(animal_age)s years old'
#skip the animal value
s = s % {'name': 'Dolly', 'animal': 'bird'}#, 'animal_age': 10}
print s
Expected Output:
Dolly has a bird that is %(animal_age)s years old
You can use two
%%in the string to skip string formatting.:or using
string.format():