teslariu

ej dicc

May 8th, 2023
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Script que pide al usuario que ingrese un paìs y su capital. Se debe
  5. # almacenar los datos en un diccionario y terminar la carga cuando se ingrese
  6. # como país la cadena "FIN". Luego, debe mostrar los datos en forma tabular
  7.  
  8. miDiccionario = {}
  9.  
  10. while True:
  11.     pais = input("Ingrese un pais (o FIN para terminar): ")
  12.     if pais == "FIN":
  13.         break
  14.     capital = input("Ingrese su capital: ")
  15.     miDiccionario[pais] = capital
  16.    
  17. print("Lista de países y capitales")
  18. for k,v in miDiccionario.items():
  19.     print(k,v)
  20.    
Advertisement
Add Comment
Please, Sign In to add comment