Advertisement
teslariu

for

Jun 14th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # TODA COLECCION ES ITERABLE (iterar significa recorrer)
  5. # iterar es pasar por todos sus elementos
  6. # for <iterador> in <iterable>:
  7.  
  8. nombres =  ["Luisa", "Ana", "Fede", "Ariel", "Polo"]
  9.  
  10.  
  11. i = 0
  12. while i < len(nombres):
  13.     print(nombres[i])
  14.     i = i + 1
  15. print()
  16.  
  17. for nombre in ["Luisa", "Ana", "Fede", "Ariel", "Polo"]:
  18.     print(nombre)
  19.  
  20. numeros =  [1,2,3,4,5,6,7,8,9,10]
  21.  
  22. # range(valor inicial, tope, salto)
  23. for numero in range(25, -3, -6):
  24.     print(numero, end=" ")
  25.    
  26. print("\n-------------------------------")
  27.  
  28. # range(valor inicial, tope)      salto por default = 1
  29. for numero in range(25,44):
  30.     print(numero, end=" ")
  31.    
  32. print("\n-------------------------------")
  33.  
  34. # range(tope)       valor inicial x default=0, salto x default = 1
  35. for numero in range(47):
  36.     print(numero,end=" ")
  37.    
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement