< td class = "code"> # Code Python3 pour montrer comment cela fonctionne
# Ajouter un suffixe / préfixe aux lignes du list
# Utilisation de la liste de compréhension + opérateur & quot; + & quot;
# liste d`initialisation
test_list
=
[
`a`
,
`b`
,
` c`
,
`d`
]
# imprimer la liste
print
(
"La liste d`origine :"
+
str
(test_list))
# initialisation append_str
append_str
= `gfg`
# Ajouter un suffixe / préfixe aux lignes de la liste
pre_res
=
[append_str
+
sub
for
sub
dans
test_list]
suf_res
=
[sub
+
append_str
for
sub
in
test_list]
# Imprimer le résultat
print
(
"liste après le préfixe additi on :"
+
str
(pre_res))
print
(
"list after suffix addition:"
+
str
(suf_res))
Sortie : b>
La liste d`origine : [`a`, `b`,` c`, `d`] liste après l`ajout du préfixe : [` gfga` , `gfgb`,` gfgc`, `gfgd`] ajout d`afterix à la liste : [` agfg`, `bgfg`,` cgfg `,` dgfg`]
Shop
Learn programming in R: courses
$
Best Python online courses for 2022
$
Best laptop for Fortnite
$
Best laptop for Excel
$
Best laptop for Solidworks
$
Best laptop for Roblox
$
Best computer for crypto mining
$
Best laptop for Sims 4
$
Latest questions
NUMPYNUMPY
psycopg2: insert multiple rows with one query
12 answers
NUMPYNUMPY
How to convert Nonetype to int or string?
12 answers
NUMPYNUMPY
How to specify multiple return types using type-hints
12 answers
NUMPYNUMPY
Javascript Error: IPython is not defined in JupyterLab
12 answers
Wiki
Python OpenCV | cv2.putText () method
numpy.arctan2 () in Python
Python | os.path.realpath () method
Python OpenCV | cv2.circle () method
Python OpenCV cv2.cvtColor () method
Python - Move item to the end of the list
time.perf_counter () function in Python
Check if one list is a subset of another in Python
Python os.path.join () method