Advice on python program -


so had write program asks user input (which should 3 letter string) , outputs 6 permutations of variations of placements of letters inside string. however, professor wants output surrounded curly brackets whereas mine list (so square brackets). how fix this? also, how check if none of letters in input repeat main program keeps asking user enter input , check error?

thank you

ok, 1 thing, here has said, print '{'. other that, can use following code in script check repeated words,

 letterlist = []   def takeinput(string):     x in string:         if x not in letterlist:             letterlist.append(x)         else:             return 0     return 1 

then asking input , checking errors, can by,

while(true): #or other condition     string = input("enter 3 letter string")     if len(string)!=3:         print("string size inadequate")         continue     if takeinput(string):         arraylist = permutation(string) #--call permutation method here         #then iterate permutations , print them in {}         x in arraylist: print("{" + x + "}")     else:         print("at least 1 of letters used") 

Comments