JPablos

Indexar simple. Python

May 11th, 2022 (edited)
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. Indexar, simple
  2.  
  3. Programa
  4. ========
  5.         #!/usr/bin/env python
  6.  
  7.         # -*- coding: utf-8 -*-
  8.  
  9.  
  10.         fruta = (input('fruta: '))
  11.  
  12.         index = 0
  13.         while index < len(fruta):
  14.    
  15.             letra = fruta[index]
  16.  
  17.             print(f'{"Índice":<3} {index:^5} {"para"} {letra:>3}')
  18.    
  19.             index = index + 1
  20.  
  21. Texto de prueba:
  22. ================
  23.                 Piña
  24.  
  25. Salida
  26. ======
  27.                 fruta: piña
  28.                 Índice   0   para   p
  29.                 Índice   1   para   i
  30.                 Índice   2   para   ñ
  31.                 Índice   3   para   a
Add Comment
Please, Sign In to add comment