plot.savefig('hanning(%d).pdf' % num)
The %
operator, when following a string, allows you to insert values into that string via format codes (the %d
in this case). For more details, see the Python documentation:
https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting