python - python3, how to repeat a list of character -



python - python3, how to repeat a list of character -

goodmorning, have problem next function:

aminoacids = ['a', 'r', 'n', 'd', 'c', 'q', 'e', 'g', 'h', 'i', 'l', 'k', 'm', 'f', 'p', 's', 't', 'w', 'y', 'v'] pair_no_change = ['a', 'k'] original_pairs = [['a', 'k'], ['a', 'k'], ['a', 'k'], ['a', 'k'], ['a', 'k'],['d', 'e'], ['s', 'f'], ['b', 'c'], ['y', 'v'], ['k', 'w']] fq = 5 def frequency(original_pairs, pair_no_change, fq): updated_pairs = list(list()) pair in original_pairs: if pair != pair_no_change: pair[0] *= fq pair[1] *= fq updated_pairs.append([pair[0], pair[1]]) else: go on homecoming updated_pairs updated_pairs = frequency(original_pairs, pair_no_change, fq) #print(updated_pairs) pair in updated_pairs: print(pair)

this function gives me next output:

['ddddd', 'eeeee'] ['sssss', 'fffff'] ['bbbbb', 'ccccc'] ['yyyyy', 'vvvvv'] ['kkkkk', 'wwwww']

i need output like:

['d','e'] ['d','e'] ['d','e'] ['d','e'] ['d','e'] ['s','f'] ['s','f'] ['s','f'] ['s','f'] ['s','f'] etc.

i think there wrong in way wrote loop, when wrote pair[0] *= fq. give thanks time , answer!

just add together loop @ last.

aminoacids = ['a', 'r', 'n', 'd', 'c', 'q', 'e', 'g', 'h', 'i', 'l', 'k', 'm', 'f', 'p', 's', 't', 'w', 'y', 'v'] pair_no_change = ['a', 'k'] original_pairs = [['a', 'k'], ['a', 'k'], ['a', 'k'], ['a', 'k'], ['a', 'k'],['d', 'e'], ['s', 'f'], ['b', 'c'], ['y', 'v'], ['k', 'w']] fq = 5 def frequency(original_pairs, pair_no_change, fq): updated_pairs = list(list()) pair in original_pairs: if pair != pair_no_change: pair[0] *= fq pair[1] *= fq updated_pairs.append([pair[0], pair[1]]) else: go on homecoming updated_pairs updated_pairs = frequency(original_pairs, pair_no_change, fq) #print(updated_pairs) pair in updated_pairs: ,j in zip(list(pair[0]), list(pair[1])): print [i,j]

output:

['d', 'e'] ['d', 'e'] ['d', 'e'] ['d', 'e'] ['d', 'e'] ['s', 'f'] ['s', 'f'] ['s', 'f'] ['s', 'f'] ['s', 'f'] ['b', 'c'] ['b', 'c'] ['b', 'c'] ['b', 'c'] ['b', 'c'] ['y', 'v'] ['y', 'v'] ['y', 'v'] ['y', 'v'] ['y', 'v'] ['k', 'w'] ['k', 'w'] ['k', 'w'] ['k', 'w'] ['k', 'w']

python list function python-3.x

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -