script output appears correct but still raises AssertionError

Chris Angelico rosuav at gmail.com
Tue Jun 6 21:02:15 EDT 2017


On Wed, Jun 7, 2017 at 10:58 AM, john polo <jpolo at mail.usf.edu> wrote:
> I am learning about assertions. I wrote a small script that takes 2 inputs,
> an amino acid sequence and one residue symbol. The script should return what
> percent of the sequence is residue in output. The point of this script is to
> use assert for debugging. My script seems to work correctly, but when I use
> the assert statements that are supposed to test the script, the assertions
> indicate there is a problem with the script.
>
>
>>>> def aminosleft(sequence, res):
> ...     sequp = sequence.upper()
> ...     lens1 = len(sequp)
> ...     rep = res.upper()
> ...     reps2 = sequp.replace(rep,"")
> ...     lens2 = len(reps2)
> ...     resid = 100* (lens1 - lens2) / lens1
> ...     print(int(resid))
> ...
> ...
>
> The script returns an integer. I don't know if the assertion uses an integer
> or if that matters. What is causing the AssertionError?

No, it doesn't. It's not returning anything (which means it's
returning None). Look carefully at the function again, and make it
actually return something.

ChrisA



More information about the Python-list mailing list