I have a four inputs values from user as follows:
numbers[1, 2]
numbersLetters={'E': 1,'K': 2}
RandomFrequency="0.5"
Here, My aim is to randomize the numbers list and get the random no which has > 0.5.
Then, get the letter of selected random no from numbersLetters dictionary.
Finally, append all the matched random no along with respective letter in single tuples inside the list of another list.
Expected OUPUT something like this:
[[('1', 'E'), ('2', 'K')]]
WHAT I get:
[[('1', 'E')], [('2', 'K')]]
My script
import random
def randomMutation(numbers,numbersLetters,MF):
mut=[]
for res,pos in numbersLetters.iteritems():
r = random.choice([x for x in numbers if x > MF])
if pos==r:
fp=int(pos)-1
mut.append([tuple(str(pos)+res)])
print mut
if __name__ == '__main__':
randomMutation([1, 2],{'E': 1,'K': 2},"0.5")
Aucun commentaire:
Enregistrer un commentaire