[Tutor] A Multiple Concatenation Problem

Alan Gauld alan.gauld at yahoo.co.uk
Sat Sep 19 19:59:55 EDT 2020


On 19/09/2020 23:26, Stephen P. Molnar wrote:

> 2-Phloroeckol.1.log
...
> 2-Phloroeckol.9.log
> 2-Phloroeckol.10.log
> 7-Phloroeckol.1.log
> 7-Phloroeckol.2.log
...> 7-Phloroeckol.10.log
> Aloeemodin.1.log
> Aloeemodin.2.log
> <...cut...>
> Vescalagin.10.log
> .1.log    |
> .2.log    |
> .3.log    |
> .4.log    |
> .5.log    |     <-- not sure where these came from, but the rest is 
> exactly what I wannted.


It suggests you have an empty line at the end of your file.
If you don;t like these simply add a check that ligand
is not "" before creating the filename.

    if ligand:
       for suf in range(1, 11):
           filename = f"{ligand[:-1]}.{suf}.log"

Blank lines in the input will then be ignored.
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list