convertisseur_str_to_list.py

Created by gengisclan

Created on August 04, 2023

1007 Bytes

Convertis une chaine de caractère type liste en liste et gère la plupart des erreurs d’écriture


def Rectifieur(chaine,chaine_sec="",test=True,chang=False):  
  while chaine[0]==",":
    if chaine==",":return ""
    chaine=chaine[1:]
  while chaine[-1]==",":
    if chaine==",":return ""
    chaine=chaine[:-1]
  while test:
    if chaine==",":return ""
    test=False
    for indice in range(len(chaine)-1):
      if chaine[indice]=="," and chaine[indice+1]==",":
        chaine_sec=Decoupeur(chaine,indice)
        test=True
        chang=True
    if chang==True:
      chaine=chaine_sec
  return chaine  
  
def Convertisseur(chaine,tampon="",L_taux=[]):
  if chaine=="":return []
  for i in chaine:
    if i==",":
      L_taux.append(int(tampon))
      tampon=""
    else:tampon+=i
  if L_taux==[]:
    L_taux.append(int(tampon))
  L_taux.append(int(tampon))
  return L_taux

  
  
  
def Decoupeur(chaine,indice,chaine_sec=""):
  for j in range(indice):
    chaine_sec+=chaine[j]
  for k in range(indice+1,len(chaine)):
    chaine_sec+=chaine[k]
  return chaine_sec

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.