-1

This is my code

string='AABCAAADA'
k=3
for i in range(0,len(string),k):
    print(set(string[i:i+k]))

each time I run it produces a different output. how can i fix this?
outputs:

{'B', 'A'}
{'A', 'C'}
{'D', 'A'}
{'B', 'A'}
{'C', 'A'}
{'D', 'A'}
{'A', 'B'}
{'A', 'C'}
{'A', 'D'}
Morteza Saki
  • 7
  • 1
  • 4

1 Answers1

1

Because set() returns set, which by design is unordered collection.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141