Intro To Python
Intro To Python
1.1 Variables
1.1 Variabile
Below are quick notes about Python variables and other most important things to know
before writing actual Python code:
• A Variable is a location in memory where we store the data.
• A variable in Python can either be of 3 data types: integer, float, or a string.
Data type specifies the category of the variables.
• We can use type(variable_name) to find the type of given variable_name.
• In Python, we use # to add comments. Comments do not change anything and are not
compiled.
• If your comment is longer than one line, you can use triple quotes. The lines inside
triple quotes are ignore during runtime.
"""
In Python, there is no official way to write long comments, but you can use
triple quotes.
The sentence between triple quote are ignored at runtime. You can also use
single quote('''....'''). Python treats single quote as double quotes in many
scanerios such as strings representation.
int_var = 1
str_var = 'Hundred'
1.2 Numbers
Numbers in Python can either be integers int or floats float. Integer are real, finite,
natural or whole numbers. Take an example: 1,2,3,4 are integers. Floats are numbers that
have decimal points such as4.6, 6.0, 7.7. Note that 4.0 is considered as a float data type
too. Recently, Karpathy, AI Director at Tesla posted that floats are not real.
We can perform operations on numbers. The operations that we can perform include
addition, multiplication, division, modular, etc...
1.2 Numere
Numerele în Python pot fi fie numere întregi int, fie floats float. Numerele întregi sunt
numere reale, finite, naturale sau întregi. Luați un exemplu: 1,2,3,4 sunt numere întregi.
Flotantele sunt numere care au zecimale, cum ar fi „4,6”, „6,0”, „7,7”. Rețineți că „4.0” este
considerat și un tip de date flotant. Recent, Karpathy, director AI la Tesla, a postat că
floaturile nu sunt reale.
Putem efectua operații pe numere. Operațiile pe care le putem efectua includ adunare,
înmulțire, împă rțire, modulare etc...
int_var = 10
float_var = 12.8
type(int_var)
int
type(float_var)
float
# Numeric Operations
# Addition
1 + 100
101
# Multiplication
1 * 100
100
# Division
1 / 100
0.01
# Floor division
7 // 2
3
# Modular (%)
# This is the remainder or a value remaining after dividing two numbers
# 100 / 1 = 100, remainder is 0
100 % 1
1 % 100
10 % 2
# Powers
# 1 power any number is 1 always
1 ** 100
2 ** 2
print(1 + 100)
101
1.3 Strings
Python supports strings. String is a sequence of characters.
Strings are one of the commonly used and important data types. Most problems involve
working with strings. Thus, knowing how to work with strings is an incredible thing.
Strings are expressed in either "..." or '...'.
"text inside here will be a string"
'text inside here will also be a string'
We can manipulate strings in many ways. A simple example is to concat the strings.
1.3 șiruri
Python acceptă șiruri. Ș irul este o secvență de caractere.
Ș irurile de caractere sunt unul dintre tipurile de date frecvent utilizate și importante. Cele
mai multe probleme implică lucrul cu șiruri. Astfel, a ști să lucrezi cu corzi este un lucru
incredibil.
Ș irurile de caractere sunt exprimate fie în „”...”” fie în „...””.
„textul aici va fi un șir”
„textul dinăuntru aici va fi și un șir”
Putem manipula șirurile în multe feluri. Un exemplu simplu este concatarea șirurilor.
str_var = 'One'
str_var2 = 'Hundred'
str_var + str_var2
'OneHundred'
This is a string
False
True
Strings Methods
Python provides many built-in methods for manipulating strings. As a programmer,
knowing typical string methods and how to use them will give you a real leverage when
working with strings.
There are many string methods. You can find them here. Let's see some common methods.
Metode șiruri
Python oferă multe metode încorporate pentru manipularea șirurilor de caractere. În
calitate de programator, cunoașterea metodelor tipice de șiruri și modul de utilizare a
acestora vă va oferi o pâ rghie reală atunci câ nd lucrați cu șiruri.
Există multe metode cu șiruri. Le puteți gă si aici. Să vedem câ teva metode comune.
sentence = 'This IS A String'
# Case capitalization
# It return the string with first letter capitalized and the rest being lower
cases.
sentence.capitalize()
'This is a string'
sentence.upper()
'THIS IS A STRING'
sentence.lower()
'this is a string'
sentence.split()
Lastly, we can use replace() method to replace some characters in string with another
characters. Replace method takes two inputs: characters to be replaced, and new
characters to be inserted in string, replace('characters to be replaced', 'new
characters').
Example, given the string "This movie was awesome", replace the world movie with
project.
În cele din urmă , putem folosi metoda replace() pentru a înlocui unele caractere din șir cu
alte caractere. Metoda de înlocuire necesită două intră ri: caractere care urmează să fie
înlocuite și caractere noi care trebuie introduse în șir, replace('caracterele de
înlocuit', 'caractere noi').
De exemplu, avâ nd în vedere șirul „Acest film a fost grozav”, înlocuiți lumea „film” cu
„proiect”.
stri = "This movie was awesome"
stri.replace('movie', 'project')
'The%20future%20is%20great'
As you can see, strings methods are powerful and can save you time. Remember one of the
Python philosophies that we saw in the beginning: Simple is better than complex.
După cum puteți vedea, metodele cu șiruri sunt puternice și vă pot economisi timp.
Amintiți-vă una dintre filozofiile Python pe care le-am vă zut la început: „Simplu este mai
bine decâ t complex”.
2. Data Structures
2. Structuri de date
Data structures are used to organize and store the data. Algorithms supports operations on
data.
Python has 4 main data structures: Lists, Dictionaries, Tuples and Sets.
Structurile de date sunt folosite pentru a organiza și stoca datele. Algoritmii acceptă
operațiuni pe date.
Python are 4 structuri principale de date: Liste, Dicționare, Tuple și Seturi.
2.1 List
2.1 Lista
A list is a set of ordered values. Each value in a list is called an element or item and can be
identified by an index. A list supports different data types, we can have a list of integers,
strings, and floats.
What we will see with Python lists:
• Creating a list
• Accessing elements in a list
• Slicing a list
• Changing elements in a list
• Traversing a list
• Operations on list
• Nested lists
• List methods
• List and strings
O listă este un set de valori ordonate. Fiecare valoare dintr-o listă este numită „element”
sau „articol” și poate fi identificată printr-un index. O listă acceptă diferite tipuri de date,
putem avea o listă de numere întregi, șiruri și elemente flotante.
Ce vom vedea cu listele Python:
• Crearea unei liste
• Accesarea elementelor dintr-o listă
• Tă ierea unei liste
• Schimbarea elementelor dintr-o listă
• Parcurgerea unei liste
• Operațiuni pe listă
• Liste imbricate
• Enumeră metode
• Listă și șiruri
Creating a List
A python list can be created by enclosing elements of similar or different data type in
square brackets [...], or with range() function.
for i in nums:
print(i)
0
1
2
3
4
week_days[0]
'Mon'
even_numbers[2]
print(even_numbers[-1])
10
Slicing a list
week_days[-4:]
week_days[:4]
week_days[2:]
names[-1] = 'Sun'
names
['James', 'Nyandwi', 'Ras', 'Sun']
names[0] = 'Francois'
names
In order to delete a given element in a list, we can empty slice it but the better way to delete
element is to use del keyword.
Pentru a șterge un anumit element dintr-o listă , îl putem goli, dar cel mai bun mod de a
șterge elementul este să folosiți cuvâ ntul cheie del.
# Delete Nyandwi in names list
del names[1]
names
If you know the index of the element you want to remove, you can use pop(). If you don't
provide the index in pop(), the last element will be deleted.
Dacă cunoașteți indexul elementului pe care doriți să îl eliminați, puteți utiliza pop(). Dacă
nu furnizați indexul în pop(), ultimul element va fi șters.
names = ['James', 'Jean', 'Sebastian', 'Prit']
names.pop(2)
names
Also, we can use remove() to delete the element provided inside the remove() method.
names = ['James', 'Jean', 'Sebastian', 'Prit']
names.remove('James')
names
Traversing a list
James
Jean
Sebastian
Prit
# Given a list nums, add 1 to the first element, 2 to the second, 3 to 3rd
element, 4 to 4th element
# Example: nums = [1,2,3,6] will be nums_new = [2,4,6,10]
nums = [1, 2, 3, 6]
nums_new = []
nums_new
[2, 4, 6, 10]
Operations on list
Operațiuni pe listă
# Concatenating two lists
a = [1,2,3]
b = [4,5,6]
c = a + b
c
[1, 2, 3, 4, 5, 6]
[None] * 5
[True] * 4
[1,2,4,5] * 2
[1, 2, 4, 5, 1, 2, 4, 5]
Nested lists
Liste imbricate
# Creating a list in other list
nested_list[3]
nested_list[1]
List Methods
Python also offers methods which make it easy to work with lists. We already have been
using some list methods such as pop() and append() but let's review more other methods.
Listează metode
Python oferă , de asemenea, metode care facilitează lucrul cu liste. Am folosit deja unele
metode de listă , cum ar fi pop() și append(), dar haideți să revizuim mai multe alte metode.
# Sorting a list with sort()
even_numbers = [2,14,16,12,20,8,10]
even_numbers.sort()
even_numbers
even_numbers.reverse()
even_numbers
even_numbers = [2,14,16,12,20,8,10]
even_numbers.append(40)
even_numbers
even_numbers.remove(2)
even_numbers
even_numbers = [2,14,16,12,20,8,10]
even_numbers.pop(1)
14
# pop() without index specified will return the last element of the list
even_numbers = [2,14,16,12,20,8,10]
even_numbers.pop()
10
even_numbers = [2,2,4,6,8]
even_numbers.count(2)
2
List and strings
Listă și șiruri
We previously have learned about strings. Strings are sequence of characters. List is a
sequence of values.
Am învă țat anterior despre șiruri. Ș irurile sunt o secvență de caractere. Lista este o
succesiune de valori.
# We can convert a string into list
stri = 'Apple'
list(stri)
The split() string method allows to specify the character to use a a boundary while splitting
the string. It's called delimiter.
Metoda șirului split() permite specificarea caracterului pentru a utiliza o limită în timp ce
împă rțirea șirului. Se numește delimitator.
stri_3 = "state-of-the-art"
stri_3.split('-')
2.2 Dictionaries
2.2 Dicționare
Dictionaries are powerful Python builtin data structure that are used to store data of key
and values. A dictionary is like a list but rather than using integers as indices, indices in
dictionary can be any data type. Also, unlike lists, dictionary are unordered. Dictionaries
dont guarrantee keeping the order of the data.
Generally, a dictionary is a collection of key and values. A dictionary stores a mapping of
keys and values. A key is what we can refer to index.
What we will see:
• Creating a dictionary
• Accessing values and keys in dictionary
• Solving counting problems with dictionary
• Traversing a dictionary
• The setdefault() method
Dicționarele sunt puternice structuri de date încorporate în Python, care sunt folosite
pentru a stoca date ale cheilor și ale valorilor. Un dicționar este ca o listă , dar în loc să
folosească numere întregi ca indici, indicii din dicționar pot fi orice tip de date. De
asemenea, spre deosebire de liste, dicționarul este neordonat. Dicționarele nu garantează
pă strarea ordinii datelor.
În general, un dicționar este o colecție de chei și valori. Un dicționar stochează o mapare a
cheilor și a valorilor. O cheie este ceea ce ne putem referi la index.
Ce vom vedea:
• Crearea unui dicționar
• Accesarea valorilor și cheilor în dicționar
• Rezolvarea problemelor de numă rare cu dicționar
• Parcurgâ nd un dicționar
• Metoda setdefault().
Creating a dictionary
countries_code = dict()
print(countries_code)
{}
dict
Let's add items to the empty dictionary that we just created.
Să adă ugă m elemente la dicționarul gol pe care tocmai l-am creat.
# Adding items to the empty dictionary.
countries_code["United States"] = 1
countries_code
{'United States': 1}
Let's create a dictionary with {}. It's the common way to create a dictionary.
Să creă m un dicționar cu {}. Este modalitatea obișnuită de a crea un dicționar.
countries_code = {
"United States": 1,
"China": 86,
"Rwanda":250,
"Germany": 49,
"India": 91,
}
countries_code
{'United States': 1, 'China': 86, 'Rwanda': 250, 'Germany': 49, 'India': 91}
To add key and values to a dictionary, we just add the new key to [ ] and set its new value.
See below for example...
Pentru a adă uga cheie și valori la un dicționar, adă ugă m noua cheie la [ ] și setă m noua ei
valoare. Vezi mai jos de exemplu...
countries_code['Australia'] = 61
countries_code
{'United States': 1,
'China': 86,
'Rwanda': 250,
'Germany': 49,
'India': 91,
'Australia': 61}
countries_code["Rwanda"]
250
True
# Should be False
"Singapore" in countries_code
False
To get all the keys, value, and items of the dictionary, we can respectively use keys(),
values(), and items() methods.
Pentru a obține toate cheile, valoarea și elementele dicționarului, putem folosi metodele
keys(), values() și, respectiv, items().
# Getting the keys and the values and items of the dictionary
dict_keys = countries_code.keys()
dict_values = countries_code.values()
dict_items = countries_code.items()
Lastly, we can use get() method to return the value of a specified key. Get method allows
to also provide a value that will be returned in case the key doesn't exists. This is a cool
feature!!
În cele din urmă , putem folosi metoda get() pentru a returna valoarea unei chei
specificate. Metoda Get permite, de asemenea, să furnizeze o valoare care va fi returnată în
cazul în care cheia nu există . Aceasta este o caracteristică cool!!
# Get the value of the Australia
countries_code.get('Australia')
61
countries_code.get('UK', 41)
41
Traversing a dictionary
We previously used for loop in dictionary to iterate through the values. Let's review it
again.
Parcurgând un dicționar
Am folosit anterior pentru buclă în dicționar pentru a itera prin valori. Să o revizuim din
nou.
countries_code
{'United States': 1,
'China': 86,
'Rwanda': 250,
'Germany': 49,
'India': 91,
'Australia': 61}
United States 1
China 86
Rwanda 250
Germany 49
India 91
Australia 61
Metoda setdefault().
Metoda setdefault() vă permite să setați o valoare pentru o anumită cheie care nu are deja
o cheie. Acest lucru poate fi util atunci câ nd doriți să actualizați dicționarul cu o nouă
valoare în cazul în care cheia pe care o că utați nu există .
countries_code.setdefault("UK", 41)
41
countries_code
{'United States': 1,
'China': 86,
'Rwanda': 250,
'Germany': 49,
'India': 91,
'Australia': 61,
'UK': 41}
Cool! The UK value is added to the dictionary because it was not in the dictionary before.
The setdefault() method and get() method are different.
We can also use the setdefault() in the count program we wrote above.
Misto! Valoarea din Marea Britanie este adă ugată la dicționar deoarece nu era în dicționar
înainte. Metoda setdefault() și metoda get() sunt diferite.
De asemenea, putem folosi setdefault() în programul de numă rare pe care l-am scris mai
sus.
stri = input(str) #input must be a string
char_count = {}
for c in stri:
char_count.setdefault(c,0) #If character doesn't exist in char_count, add
it and set it to 0
char_count[c] += 1
print(char_count)
<class 'str'>AAAHHSHSHS
{'A': 3, 'H': 4, 'S': 3}
Summarizing dictionary
• Dictionaries are not ordered and they can not be sorted - list are ordered (and
unordered) and can be sorted.
• Dictionary can store data of different types: floats, integers and strings and can also
store lists.
2.3 Tuples
Tuple is similar to list but the difference is that you can't change the values once it is
defined (termed as immutability). Due to this property it can be used to keep things that
you do not want to change in your program. Example can be a country codes, zipcodes, etc...
2.3 Tupluri
Tuplu este similar cu lista, dar diferența este că nu puteți modifica valorile odată ce este
definit (numit „imuabilitate”). Datorită acestei proprietă ți, poate fi folosit pentru a pă stra
lucruri pe care nu doriți să le modificați în program. Un exemplu poate fi un cod de țară ,
coduri poștale etc...
tup = (1,4,5,6,7,8)
# Indexing
tup[4]
## Tuples are not changeable. Running below code will cause an error
# tup[2] = 10
# You can not also add other values to the tuple. This will be error
#tup.append(12)
2.4 Sets
2.4 Seturi
Sets are used to store the unique elements. They are not ordered like list.
Seturile sunt folosite pentru a stoca elementele unice. Nu sunt ordonate ca lista.
set_1 = {1,2,3,4,5,6,7,8}
set_1
{1, 2, 3, 4, 5, 6, 7, 8}
set_2 = {1,1,2,3,5,3,2,2,4,5,7,8,8,5}
set_2
{1, 2, 3, 4, 5, 7, 8}
As you can see, set only keep unique values. There can't be a repetition of values.
După cum puteți vedea, setați doar pă strați valori unice. Nu poate exista o repetare a
valorilor.
# List Vs Set
odd_numbers = [1,1,3,7,9,3,5,7,9,9]
print("List:{}".format(odd_numbers))
print("********")
set_odd_numbers = {1,1,3,7,9,3,5,7,9,9}
print("Set:{}".format(set_odd_numbers))
List:[1, 1, 3, 7, 9, 3, 5, 7, 9, 9]
********
Set:{1, 3, 5, 7, 9}
True
## Equal to
100 == 1
False
## Less than
100 < 1
False
## Greater or equal to
100 >= 1
True
## Less or equal to
100 <= 1
False
False
True
Logic operators are used to compare two expressions made by comparison operators.
• Logic and returns true only when both expressions are true, otherwise false.
• Logic or returns true when either any of both expressions is true. Only false if both
expressions are false.
• Logic not as you can guess, it will return false when given expression is true, vice
versa.
Operatorii logici sunt folosiți pentru a compara două expresii realizate de operatorii de
comparare.
și logic returnează adevărat numai când ambele expresii sunt adevărate, în caz contrar false.
sau logic returnează adevă rat atunci câ nd oricare dintre ambele expresii este adevă rată .
Fals numai dacă ambele expresii sunt false.
• Logica „nu” așa cum puteți ghici, va returna fals atunci câ nd expresia dată este
adevă rată , invers.
100 == 100 and 100 == 100
True
False
True
100 == 10 or 100 == 10
False
not 1 == 2
True
not 1 == 1
False
4. Control Flow
As an engineer, you will need to make decisions depending on the particular situation. You
will also need to control the flow of the program and this is where Control Flow comes in.
We will cover:
• If statement
• For loop
• While loop
4. Controlul fluxului
Ca inginer, va trebui să iei decizii în funcție de situația particulară . De asemenea, va trebui
să controlați fluxul programului și aici intervine Control Flow.
Vom acoperi:
Declarația If Pentru buclă
• bucla While
else:
do this
if 100 < 2:
if 100 > 2:
if 100 < 2:
else:
print('Printed')
Printed
# Let's assign a number to a variable name 'jean_age' and 'yannick_age'
john_age = 30
luck_age = 20
else:
print(" John is younger than Luck")
john_age = 30
luck_age = 20
yan_age = 30
else:
print("John's age is same as Yan")
We can also put if condition into one line of code. This can be useful when you want to
make a quick decision between few choices.
Here is the structure:
'value_to_return_if_true' if condition else 'value_to_return_if_false'
num = 45
'Odd'
nums = [1,2,3,4,5,6]
True
even_nums = [2,4,6,8,10]
2
4
6
8
10
Mon
Tue
Wed
Thur
Fri
United States
India
Germany
China
Rwanda
1
91
49
86
250
For can also be used to iterate over an sequence of numbers. Range is used to generate the
sequence of numbers.
for number in range:
do something
0
1
2
3
4
5
6
7
8
9
for number in range(10, 20):
print(number)
10
11
12
13
14
15
16
17
18
19
One last thing about for loop is that we can use it to make a list. This is called list
comprehension.
Un ultim lucru despre for loop este că îl putem folosi pentru a face o listă . Aceasta se
numește înțelegerea listei.
letters = []
letters
['M', 'a', 'c', 'h', 'i', 'n', 'e', 'L', 'e', 'a', 'r', 'n', 'i', 'n', 'g']
letters
['M', 'a', 'c', 'h', 'i', 'n', 'e', 'L', 'e', 'a', 'r', 'n', 'i', 'n', 'g']
a = 10
while a < 20:
print('a is: {}'.format(a))
a = a + 1
a is: 10
a is: 11
a is: 12
a is: 13
a is: 14
a is: 15
a is: 16
a is: 17
a is: 18
a is: 19
5. Functions
Functions are used to write codes or statements that can be used multiple times with
different parameters.
One fundamental rule in programming is "DRY" or Do not Repeat Yourself. Functions will
help to not repeat yourself.
This is how you define a function in Python:
def function_name(parameters):
"""
This is Doc String
You can use it to notes about the functions
"""
statements
return results
• function_name is the name of the function. It must not be similar to any built in
functions. We will see built in functions later.
• Doc String is used to add notes about the function. It is not a must to use it but it is
a good practice.
• return specify something or value that you want to return everytime you call or run
your function.
5. Funcții
Funcțiile sunt folosite pentru a scrie coduri sau instrucțiuni care pot fi folosite de mai multe
ori cu parametri diferiți.
O regulă fundamentală în programare este „USCAT” sau nu te repeta. Funcțiile vă vor ajuta
să nu vă repetați.
Iată cum definiți o funcție în Python:
def function_name(parametri):
"""
Acesta este Doc String
Îl puteți folosi pentru a nota despre funcții
"""
declarații
returnează rezultatele
• return specificați ceva sau valoarea pe care doriți să o returnați de fiecare dată câ nd
apelați sau rulați funcția.
# Function to add two numbers and return a sum
def add_nums(a,b):
"""
Function to add two numbers given as inputs
It will return a sum of these two numbers
"""
sum = a+b
return sum
add_nums(2,4)
add_nums(4,5)
9
# Displaying the doc string noted early
print(add_nums.__doc__)
activity("Chris", "Francois")
activity("Kennedy", "Kleber")
As you can see, functions do not need to always have return. When you only want to
display the customized message (not involving expression), print() will be enough.
După cum puteți vedea, funcțiile nu trebuie să aibă întotdeauna „return”. Câ nd doriți să
afișați doar mesajul personalizat (nu implică expresia), print() va fi suficient.
6. Lamdba Functions
There are times that you want to create anonymous functions. These types of functions will
only need to have one expressions.
## Sum of two numbers
def add_nums(a,b):
sum = a+b
return sum
add_nums(1,3)
We can use lambda to make the same function in just one line of code! Let's do it!!
Putem folosi lambda pentru a face aceeași funcție într-o singură linie de cod! Hai să o
facem!!
sum_of_two_nums = lambda c,d: c + d
sum_of_two_nums(4,5)
7. Built in Functions
Python being a high level programming language, it has bunch of built in functions which
make it easy to get quick computations done.
An example of built in functions we used is len() which gives the length of the string or the
list givhttps://github.com/Nyandwi/python_basics/blob/main/n as the input to it.
Here is a full preview on all Python Built in functions.
15
odd_numbers = [1,3,5,7]
len(odd_numbers)
4
# Using max() to find the maximum number in a list
odd_numbers = [1,3,5,7]
max(odd_numbers)
min(odd_numbers)
odd_numbers = [9,7,3,5,11,13,15,1]
sorted(odd_numbers)
Let's learn two more useful built functions: they are map and filter. You can try to explore
or use more built in functions on your own.
Să învă ță m încă două funcții utile construite: ele sunt map și filter. Puteți încerca să
explorați sau să utilizați mai multe funcții încorporate pe cont propriu.
num_list = [0,1,2,3,4]
# Applying `map` to the num_list to just return the list where each element
is cubed...(xxx3)
list(map(cubic, num_list))
return number % 2 != 0
num_list = [1,2,4,5,6,7,8,9,10,11]
list(filter(odd_check, num_list))
[1, 5, 7, 9, 11]
nums = range(1,20)
even_nums = []
print(even_nums)
You can see it's pretty simple. And more readable than the former. Let's take another
example.
Puteți vedea că este destul de simplu. Ș i mai lizibil decâ t primul. Să luă m un alt exemplu.
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
day_T = []
# Make a list of days that start with `T`
print(day_T)
['Tuesday', 'Thursday']
['Tuesday', 'Thursday']
list(enumerate(seasons))
As you can see, each element came with index counter automatically. The counter initially
start at 0, but we can change it.
După cum puteți vedea, fiecare element a venit automat cu contor index. Contorul începe
inițial de la 0, dar îl putem schimba.
list(enumerate(seasons, start=1))
0 - Rock
1 - Paper
2 - Scissor
<zip at 0x107ebc9c0>
The zip object return nothing. In order to show the zipped elements, we can use a list. It's
also same thing for enumerate you saw above.
Obiectul zip nu returnează nimic. Pentru a afișa elementele cu fermoar, putem folosi o listă .
Este același lucru și pentru enumerarea pe care ați vă zut-o mai sus.
list(zipped_name_role)