Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1068 connectés 

  FORUM HardWare.fr
  Programmation
  Python

  créer des listes python en boucle list(n)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

créer des listes python en boucle list(n)

n°2290979
Aarkann
http://www.framasoft.net/
Posté le 01-11-2016 à 11:24:02  profilanswer
 

Bonjour,
 
Avec Python, Est il possible de créer des listes en boucles ?
par exemple pour x allant de 1 à 10
 
avec  list (x) = [ ]
 
Je ne trouve rien, sinon tout mettre bout à bout dans une seule et même liste ?
 
merci par avance  :hello:


---------------
!  ! VOTRE WEEK EN DANGER ICI ! ! !                          ! MAGEIA
mood
Publicité
Posté le 01-11-2016 à 11:24:02  profilanswer
 

n°2290998
caps lock
Posté le 02-11-2016 à 13:24:38  profilanswer
 

Quelque chose comme ça?
 

Code :
  1. >>> maListe = []
  2. >>> for i in range(1,10):
  3.    maListe.append(i)
  4. >>> print(maListe)
  5. [1, 2, 3, 4, 5, 6, 7, 8, 9]

Message cité 1 fois
Message édité par caps lock le 02-11-2016 à 13:25:01
n°2291004
phraide
Posté le 02-11-2016 à 14:48:47  profilanswer
 

caps lock a écrit :

Quelque chose comme ça?
 

Code :
  1. >>> maListe = []
  2. >>> for i in range(1,10):
  3.    maListe.append(i)
  4. >>> print(maListe)
  5. [1, 2, 3, 4, 5, 6, 7, 8, 9]



 
bof ...

Code :
  1. >>> maListe=range(11)
  2. >>> maListe
  3. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


---------------
I'm too old for this shit.
n°2291024
caps lock
Posté le 02-11-2016 à 16:47:58  profilanswer
 

Il a dit de 1 à 10 ...
>>> bob = range(1,10)
>>> print(bob)
range(1, 10)
>>> bob
range(1, 10)

n°2291031
Aarkann
http://www.framasoft.net/
Posté le 02-11-2016 à 18:56:53  profilanswer
 

merci, en fat je voulais dire

Code :
  1. for k in range(100):
  2.     list(k) =[]


 
et que j'ai de crée 100 listes  lis(1), list(2) ....  list(100)
 
comme les variables en basic.


Message édité par Aarkann le 02-11-2016 à 19:01:39

---------------
!  ! VOTRE WEEK EN DANGER ICI ! ! !                          ! MAGEIA
n°2291048
caps lock
Posté le 03-11-2016 à 09:08:46  profilanswer
 

:pt1cable:  
>>> listeDeListe = [[] for x in range(100)]
>>> listeDeListe
[[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Python

  créer des listes python en boucle list(n)

 

Sujets relatifs
Creer un bouton macro plusieurs feuilles d'un classeurProblème avec boucle foreach powershell
Python class et méthodologie, une folle histoire de bonbonsfind à l'envers en Python ?
boucle de dico et liste[Python] Installation et Packages
Creer une chaîne de N "espaces"je n'arrive pas a créer un menu déroulant avec mes div
[VB.NET] Créer un formulaire a partir d'une classeCreer un ficher texte
Plus de sujets relatifs à : créer des listes python en boucle list(n)


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR