I have an assignment to turn in for the University. I already got the correct result in VS Code with the code below (the idea is to show the car with the lowest consumption):
def entrada_carro():
carro = []
for i in range(4):
carro.append(input("Digite o modelo do carro: "))
return carro
def entrada_consumo():
consumo = []
for i in range(4):
consumo.append(int(input("Digite o consumo do carro: ")))
return consumo
def economico(carro, consumo):
menor = consumo[0]
for i in range(1,4):
if consumo[i] < menor:
menor = consumo[i]
return carro[consumo.index(menor)]
def main():
carro = entrada_carro()
consumo = entrada_consumo()
print("O carro mais economico é o", economico(carro, consumo))
main()
Although it works. The university platform uses another main() function already, which is as follows (there is a particularity, to send on the platform I cannot have the texts inside the inputs, which does not influence; I just remove those before sending):
def main():
entrada_carro()
entrada_consumo()
print(economico())
main()
So, I just need to send all the other three functions.
And the error only occurs when I play this in the validator (the code without the part that the platform already has). Test entries are as follows:
- (result must be AUDI): JEEP AUDI BMW JAGUAR 10 6 8 12 2. (result must be UP): CELTA GOL UP KA 10 7 6 9
The article ahead didn't help me (only if I didn't understand if the answer is there): how to resolve missing 2 required positional argument python.
Can anyone help understand please? Thanks in advance!!
I have checked that there are differences between my main() and Uni's:
Mine (with declared variables):
def main():
carro = entrada_carro()
consumo = entrada_consumo()
print("O carro mais economico é o", economico(carro, consumo))
main()
And theirs (without variables declared):
def main():
entrada_carro()
entrada_consumo()
print(economico())
main()
I just don't understand the implications...