#π HI i was wondering what this was
45 messages Β· Page 1 of 1 (latest)
@ocean scarab
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.
are they converting something to something
sorry im new it might take me a while to aborb this @autumn forge
no
Is it not the same?
Can you help me out π
!e when u use dict constructor the keys cannot be literals
print(dict(0='abc'))
@warm nova :x: Your 3.12 eval job has completed with return code 1.
001 | File "/home/main.py", line 1
002 | print(dict(0='abc'))
003 | ^^
004 | SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
Ah.
give me one sec to absorb this π
basically this code will not work
Will u still be here for another 15 mins still reading something
possibly
Ty for all your help buddy π₯Ή
So what does that have to do my question sorry Iβm kinda lost
i was just showing that the code you gave would give an error
But you can do this. dict([(0, "red"), (1, "blue)])
dict is the class form of the {} literal.
The literal form can be used when all items are known at dev time (or in a generator). dict() can be used to convert other objects to a dict.
it also accepts kwargs
Even tho the code is wrong can you tell me why they put Dict first
stylistic choice probably
when you have string keys, you don't need to wrap the keys in quotes when using dict(x=y)
vs {"x": y}
Is a string key a data type
class str(object='')``````py
class str(object=b'', encoding='utf-8', errors='strict')```
Return a [string](https://docs.python.org/3/library/stdtypes.html#textseq) version of *object*. If *object* is not provided, returns the empty string. Otherwise, the behavior of `str()` depends on whether *encoding* or *errors* is given, as follows.
If neither *encoding* nor *errors* is given, `str(object)` returns [`type(object).__str__(object)`](https://docs.python.org/3/reference/datamodel.html#object.__str__), which is the βinformalβ or nicely printable string representation of *object*. For string objects, this is the string itself. If *object* does not have a [`__str__()`](https://docs.python.org/3/reference/datamodel.html#object.__str__) method, then [`str()`](https://docs.python.org/3/library/stdtypes.html#str) falls back to returning [`repr(object)`](https://docs.python.org/3/library/functions.html#repr).
or ""
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.