0
I’m having a problem in this Python code where, when I try to run, it informs me that there is a syntax error in a else
. Follow the code and error below:
n=int(raw_input(''))
i=0
for i in xrange(0,n):
num_poco=int(raw_input(''))
tipo_do_poco=raw_input('')
custo_poco=float(raw_input(''))
if tipo_do_poco.upper() == P or tipo_do_poco.upper() == G:
vazao=float(raw_input(''))
enxofre=float(raw_input(''))
if enxofre == E:
taxa_enxofre=float(raw_input(''))
elif enxofre != E:
taxa_enxofre=0.0
else:
vazao=0.0
taxa_enxofre=0.0
lucro=0.0
receita=0.0
print'============================================'
print('Empresa de Perfuracoes Furo Certo S/A.')
print('Poco no.: %d'%(num_poco))
print('Custo do Poco : R$%11.2f'%(custo_poco))
if tipo_do_poco == P:
print('Volume de Petroleo encontrado: %11.2f'%(vazao))
receita = vazao * 5.50 * (1 - taxa_enxofre)
elif tipo_do_poco == G:
print('Volume de Gas encontrado: %11.2f'%(vazao))
receita = vazao * 2.20 * (1 - taxa_enxofre)
else:
print('Volume de encontrado: %11.2f'%(vazao))
receita = 0.00
lucro=receita-custo_poco
if (receita - custo_poco)>50000.00:
print('Lucro do Poco (gusher) : R$%11.2f\n'%(lucro)
else:
print('Lucro do Poco : R$%11.2f\n'%(lucro)
#print('============================================')
#print('')
custo_total = (total_custo+custo_poco):
total_receita = (total_receita+receita):
total_lucro = (total_lucro+lucro):
print('=======================================')
print"Empresa de Perfuracoes Furo Certo S/A."
print('Total de Pocos : %d'%(num_poco)
print('Total dos Custos : R$%11.2f'%(total_custo)
print('Total da Receita : R$%11.2f'%(total_receita)
print('Total do Lucro : R$%11.2f'%(total_lucro)
print('=======================================')
Traceback (Most recent call last): File "python", line 41 Else:print('Poco profit : R$%11.2f n'%(profit) Syntaxerror: invalid syntax
Parentheses were missing from
print
of the latterelse
. And parentheses in theprint
of the latterif
also– Jefferson Quesado
There are so many syntax errors that it is difficult to list them all. Parentheses on lines 40 and 42, 51, 52, 53 and 54; Two dots remaining on lines 46, 47 and 48; Function
print
with parentheses in Python version 2.7; very weird indentation for a Python script; and move on.– Woss