User Profile

Collapse

Profile Sidebar

Collapse
AuroraBorealis
AuroraBorealis
Last Activity: Mar 12 '10, 09:04 PM
Joined: Oct 27 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • AuroraBorealis
    started a topic Converting a string into integers

    Converting a string into integers

    I have to write this short program that converts digits/symbols in a string into integers. Basically it takes a string containing none or one operation sign "+" or "-" if __init__ allows it, followed by one or more digits, and can contain blank spaces anywhere. It then returns a triple in this format:

    (number of characters in the string including blanks, but not including blanks after the digits, "-1" if...
    See more | Go to post

  • AuroraBorealis
    replied to "Value Error" in Python
    Doesn't the index method return an integer index, if I provide it with a variable or a character, ie, basically find where in the string/list that character first appears?
    Could you explain what s1.index(c) would do please? And does s2.index(strand 2[i]) mean return the position of the ith character in strand2, as it appears in s2? Thanks.
    See more | Go to post

    Leave a comment:


  • AuroraBorealis
    replied to "Value Error" in Python
    Hi thanks for reply.
    Enumerate function basically returns a string or list in the form of ordered pairs right? enumerate('ABC' ) would turn into (0, 'A'), (1, 'B'), (2, 'C')?
    Sorry I forgot to mention that I cannot use dictionary (I just started this course), as we haven't covered them yet, so I have no idea how dictionaries work. Is there some way to only do it with loops and enumerate if that's necessary?
    See more | Go to post

    Leave a comment:


  • AuroraBorealis
    started a topic "Value Error" in Python

    "Value Error" in Python

    Hello, I'm trying to write this simple program that returns True if two equal-length strings are complimentary DNA pairs (ie, if character 1 in string 1 was 'A', character 1 in string 2 has to be 'T', and vice-versa, otherwise it would return false).
    This is what I have so far:
    Code:
    [B]for[/B] (base1, base2) [B]in [/B](strand1, strand2):
        [B]if[/B] (base1, base2) [B]not in[/B] (('A', 'T'), ('T', 'A'), ('C', 'G'), ('G', 'C')):
            [B]return Fal[/]
    ...
    See more | Go to post
    Last edited by bvdet; Oct 27 '09, 04:41 PM. Reason: Add code tags
No activity results to display
Show More
Working...