Jump to content

Problema com tabelas


GuiOlaio

Recommended Posts

Estou a fazer um programa simples, com tabelas, em python. Eu queria que os dados inseridos aparecessem organizados numa tabela, mas quando dou run, os dados aparecem me em 12 tabelas diferentes.

Código:

from tabulate import tabulate

years=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

C1=int(input("Indique o capital inicial:"))

r=int(input("Indique a taxa de juro:"))

for n in years:

s=r*0.01

Cf=C1*(1+s)**n

table=[['Tempo (em anos)', 'Capital Final (em €)'],[n , Cf]]

print(tabulate(table, tablefmt="fancy_grid", headers="firstrow"))

Edited by GuiOlaio
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.