loops - Anagram generator from input in Python malfunction -


i tried code simple generator of list of anagrams input. after rewrote code gives me 2 outputs. here's code

import random item=input("name? ") a='' b='' oo=0 while oo<=(len(item)*len(item)):     a=''.join([str(y) y in random.sample(item, len(item))]) #this line found on site     b=''.join([str(w) w in random.sample(item, len(item))]) #because in no way had success in doing myself     j=[]     j.append(a) #during loop should add anagrams generated     j.append(b) #everytime loop repeats     oo=oo+1 j=list(set(j)) #to cancel duplicates h=len(j) f=0 while f<=(h-1):     print(j[f]) 

but output gives 1 anagram repeated ever.

as far can see don't increment f @ end. rather like:

for item in j:    print( item ) 

the other thing is, overwrite j in every loop. sure wanted that?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -