Putting a variable inside a string (python)

Posted by Gish on Stack Overflow See other posts from Stack Overflow or by Gish
Published on 2010-06-02T19:05:52Z Indexed on 2010/06/02 19:14 UTC
Read the original article Hit count: 111

Filed under:
|

Hi I am quite new to python and this is probably quite a basic question but the help would be much appreciated.

I would like to put an int within a string. This is what I am doing at the moment..

end = smooth(data,window_len=40)
plot.plot(time[0:len(end)],end)
plot.savefig('hanning(40).pdf') #problem line

I have to run the program for several different numbers instead of the two 40's. So I'd like to do a loop but inserting the variable like this doesn't work:

plot.savefig('hanning',num,'.pdf')

Thanks!

© Stack Overflow or respective owner

Related posts about python

Related posts about variables