So if if 'A' is incorrect, it moves to elif and doesn't look at return?
@JourneymanGeek Whatever's easiest XD
room topic changed to Python Programming: For those who need help programming, coding and using Python [code-blocks] [programming] [python] [python-2.7] [python3]
room topic changed to Python Programming: For those who need help programming, coding and using Python. [code-blocks] [programming] [python] [python-2.7] [python3]
`Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
get_compliment('A')
File "<pyshell#2>", line 16, in get_compliment
if parameter('A'):
TypeError: 'str' object is not callable`
why are you assigning the value nucleotide to parameter then comparing that value with something, when you already assign a value when calling the function?
Because it had an error. I thought that was the answer :P
@JourneymanGeek That's... a very confusing statement. I thought that if I put the value of nucleotide into a variable, it might not get confused and say a string is not callable.
so what we'd do is use another variable to do that newdna = newdna + c
but we'd need to set an initial value outside the loop.
so.. putting all that together
newdna=''
for char in dna:
c = get_complement(char)
newdna = newdna + c
return newdna
we initialise newdna as a blank value, then run through each charecter in dna, find its compliment, then concatenate its value to newdna, once that is done, we return newdna
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
get_complimentary_sequence('AT')
File "<pyshell#17>", line 15, in get_complimentary_sequence
c = get_complement(char)
NameError: global name 'get_complement' is not defined
def get_complementary_sequence(dna):
'''(str) -> str
Returns the complementary sequence in a string.
>>>get_complementary_sequence('AT')
'TA'
>>>get_complementary_sequence('AATTCCGG')
'TTAAGGCC'
>>>get_complementary_sequence('ACGT')
'TGCA'
'''
newdna=''
for char in dna:
c = get_complement(char)
newdna = newdna + c
return newdna