Curso de Programación en Python/print-8

De WikiCabal
Ir a la navegación Ir a la búsqueda

print-8.py

 1 #!/usr/bin/python3
 2 #-*-coding: utf-8 -*-
 3 
 4 Capital_Pais={ "United States" : "Washington", 
 5                "US" : "Washington", 
 6                "Canada" : "Ottawa",
 7                "Germany": "Berlin",
 8                "France" : "Paris",
 9                "England" : "London",
10                "UK" : "London",
11                "Switzerland" : "Bern",
12                "Austria" : "Vienna",
13                "Netherlands" : "Amsterdam" }
14 
15 print( "\nPaises y sus capitales:")
16 for c in Capital_Pais:
17     print("{Pais:^14s}: {Capital}" .format( Pais=c, Capital=Capital_Pais[c] ) )

Resultado

[rrc@Pridd PythonClase]$ ./print-8.py

Paises y sus capitales:
   Germany    : Berlin
   France     : Paris
   Austria    : Vienna
   England    : London
 Switzerland  : Bern
   Canada     : Ottawa
 Netherlands  : Amsterdam
     UK       : London
United States : Washington
     US       : Washington

Explicación