0
letter={'s', 'a', 'i', 'j', 'o', 'n'} print(letters.remove('i')) showing error. How to write it exact way? And explainto reverse
5 Antworten
+ 1
try to replace curses brackets by squares brackets (list)
use curses brackets to define a dictionary with key: value
+ 6
There is a misspelling in your code. You declared 'letter' set and you try to run a method on 'letters'.
It should go like this:
letters={'s', 'a', 'i', 'j', 'o', 'n'}
letters.remove('i')
print(letters)
reverse() can't be applied on sets, as they are variables of an unordered type.
+ 5
This is a set. As a type, it is unordered and can carry unique values only. When printed though, it usually is displayed in an ordered fashion. But that is not its intrinsic trait - it is probably somehow knit into __repr__ or __str__ method which are used by print().
Try to create a set of unique values of different types. You'll see that it is 'out of order' ;)
+ 1
Kuba.. This lead me to a question.. Why does this
letter={'s', 'a', 'i', 'j', 'o', 'n'}
print(letter)
give the following output?
{'a', 'i', 'j', 'o', 'n', 's'}
Why move the first element to the end?
0
I see.. changing a few elements to ints piled the ints together.. So out of order, in a somewhat orderly fashion.. Interesting...