Use the repeat block while. The block’s syntax is while bool:, where, it will repeat the code while the condition is True. Soon your program can stay that way:
stop = False
while not stop:
f=float(input("Digite 0 para retângulo, 1 para triângulo:"))
if f==0:
a=float(input("valor da altura:"))
b=float(input("valor da base:"))
print(a*b/2)
else:
a=float(input("valor da altura:"))
b=float(input("valor da base:"))
print(a*b)
if input("Deseja sair (Y/N) ? ").lower() == "y":
stop = True
As the value of the variable initially stop is False and I declared a not, she will have the value True in the syntax of while.
If the user type "y" or "Y", the variable stop will have the value True, and in the syntax of whilehe will have the value False. That way he gets off the block while and close the program if there is no more code below.
You want the show to run forever, that’s it?
– Daniel Mendes
I think you still haven’t seen the language at all, while maybe it’s what you want
– Elton Nunes