* fix: converted single to triple backticks13 * fix: added prefix Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: removed language in wrong place Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: add language postfix Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> * fix: removed language in wrong place Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
35 lines
1.0 KiB
Markdown
35 lines
1.0 KiB
Markdown
---
|
||
title: Learn About Python Sets
|
||
localeTitle: تعرف على مجموعات بايثون
|
||
---
|
||
`Set` s في Python هي نوع من بنية البيانات القابلة للتغيير ولكنها غير مرتبة ، والتي يمكن أن تحتوي فقط على عناصر _فريدة_ .
|
||
|
||
**خلق:**
|
||
|
||
`set` حرفية:
|
||
|
||
_لا_ يمكن استخدام الأقواس المتعرجة ، `{}` ، لإنشاء مجموعة فارغة:
|
||
|
||
```python
|
||
>>> not_set = {} # set constructor must be used to make empty sets.
|
||
>>> type(not_set) # Empty curly brackets create empty dictionaries.
|
||
<class 'dict'>
|
||
```
|
||
|
||
يمكنك فقط إنشاء مجموعة فارغة باستخدام طريقة `set()` .
|
||
|
||
```python
|
||
>>> example_set = set()
|
||
>>> type(example_set)
|
||
<class 'set'>
|
||
```
|
||
|
||
ومع ذلك ، إذا تم تضمين العناصر داخل الأقواس المتعرجة ، فسيكون بناء الجملة مقبولًا لإنشاء مجموعة.
|
||
|
||
```python
|
||
>>> example_set_2 = {1, 2, 3}
|
||
>>> type(example_set_2)
|
||
<class 'set'>
|
||
```
|
||
|
||
\` |