Set is not manageable.
In your question Voce uses the type set
to define the sequence, in python this type is a data structure that represents a sequence denoting a mathematical set, i.e., Voce cannot impose or maintain any particular order of the elements. The abstract concept of a mathematical set does not presuppose order, for example, if you create a type set
from a list, python automatically changes the order of the elements to meet the internal implementing directives of the set
optimized to execute the proposed operations for this type.
See these examples:
set={'z','b','c'}
print(set)
{'c', 'b', 'z'}
set.add('a')
print(set)
{'c', 'b', 'z', 'a'}
set.add('e')
print(set)
{'a', 'b', 'c', 'e', 'z'}
# Obs. Novos testes com os mesmos valores podem gerar resultados diferentes
You could get what you want with list
, see:
lst = [1,2,3,4,5]
lst.remove(5)
print(lst)
[1, 2, 3, 4]
lst.insert(0,5)
print(lst)
[5, 1, 2, 3, 4]
Tip:
To find the position of an element in a list, do: lst.index('elemento')
I could ask the question what you tried to do as well as the result you got?
– Woss