[Tutor] A Multiple Concatenation Problem
Mats Wichmann
mats at wichmann.us
Sat Sep 19 21:19:43 EDT 2020
On 9/19/20 5:59 PM, Alan Gauld via Tutor wrote:
> 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.
>
all of this is part of the general topic of validating your inputs: if
you're getting stuff from a file something else had generated, you
shouldn't just blindly proceed on the basis it's all correct and in the
format you expect: "Trust, but Verify" :)
More information about the Tutor
mailing list