im a complete n00b on programming, i started python and tried to code a simple list of anagrams generator from a input. But after i rewrited the code because of several errors(fixed by searching online) i've come to my final code(i want to make it by myself, don't wanna just copy and past other's code) but it gives me only 2 output. Here's the code
import random
item=input("Name? ")
a=''
b=''
oo=0
while oo<=(len(item)*len(item)):
a=''.join([str(y) for y in random.sample(item, len(item))]) #this line was found on this site
b=''.join([str(w) for w in random.sample(item, len(item))]) #because in no way i had success in doing it by myself
j=[]
j.append(a) #During the loop it should add the anagrams generated
j.append(b) #everytime the loop repeats itself
oo=oo+1
j=list(set(j)) #To cancel duplicates
h=len(j)
f=0
while f<=(h-1):
print(j[f])
But the output it gives is only one anagram repeated for ever.
Aucun commentaire:
Enregistrer un commentaire