#🔒 What’s wrong?
17 messages · Page 1 of 1 (latest)
@turbid crescent
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Yes, but tuples are immutable. You can't append to them.
But I can sort, reverse, remove, pop and insert.
Thanks
Really? Show us.
No im asking
bearing in mind that it will have stopped at the first error.
Yes it did
Oh, asking. (Use a "?") Yeah, you can't change a tuple once it's made.
tuples can't be changed. it might look like it sometimes, but they can't actually be.
So:
tup = 1,2,3
tup.sort() # no such method on tuples
tup2 = sorted(tup) # this makes a list from the tuple
What slicing works for tuples which also works for lists
you can 'sort' them for example in the sense that you can create a new tuple that is equivalent to the sorted original
Slicing makes a new object. The original is unchanged.
Ok
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.