Re: [Tutor] While Loop?

2014-05-19 Thread Alan Gauld

On 18/05/14 23:44, Sam Ball wrote:


I however would like to add in another line that tells the user their account 
is invalid
before looping around and asking them to re enter their account.


OK, Time to introdusce another Pyhon idioM, the break clause.

while True:   # loop forever
get input from user
check/convert input
if no errors:
   break   # exits the loop
print error message here

Please Input Your Account Number:)

userAccountNumber = int(userAccount)



As for users typing in a name like Charlie or a float I would like that to 
spit out
an error also, but I haven't learned how to accomplish that yet.


The code you have will detect the error and throw an exception.
To stay in the loop you need to catch those exceptions in a try/except 
clause.


while True:
   try:
  get input
  check/convert input
  break
   except error1, error2,:
  print error messages here

If you haven't covered try/except yet then you should read up on it
as it has several variations and subtleties.

HTH

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] List of Lists for three Frames

2014-05-19 Thread Wolfgang Maier

On 17.05.2014 15:26, Alan Gauld wrote:

On 17/05/14 08:01, ani wrote:

So I thought it would be cool to read a sequence at three different
frames,


A sequence of what?
And whats a frame in this context?


...I've come across a conundrum: how to make a list of lists.


outerlist = []
innerlist = [1,2,3]
outerlist.append(innerlist)
outerlist.append([4,5,6])


print (outerlist[1][1])  # prints 5


type of frame with a + or a - to signify the direction of the read
(+1,+2,
+3, -1, -2, -3),


What does 'direction of the read mean'?


the numerical position of each start codon a


Whats a codon?

This is a list for programmers learning python.
Do not assume any specialized domain knowledge.
If you can explain the problem in terms of
plain English and basic math then we can probably help.
If you use terms that are either ambiguous or too
specialized we will be lost and unable to assist.




The OP is asking about a representation of DNA sequences in Python.
More specifically, his question is about protein coding segments of DNA
that are transcribed into messenger RNA, then translated into protein
using the so-called triplet code (three RNA nucleotides are encoding one
amino acid of the protein). So the question involves a lot of basic
biology (Alan's questions: since three nucleotides stand for one amino
acid there are three different reading frames for any messenger RNA
starting with the first, second and third nucleotide, respectively; the
orignal DNA is an anti-parallel double strand and either strand may be
transcribed, so 'direction' refers to this; a codon is a specific
triplet of nucleotides).

Ani: While I could help you with your question, I agree with Peter that
you need to define much more clearly what you are trying to do before we
can discuss any code here. In principle, he's also right that you should
look into biopython because that package might well be the right thing
for you, but that, again, is hard to tell without knowing the details of
what you are trying to do.

Best wishes,
Wolfgang

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor