Specific class in Python
<p>I'm writing a program that calculates fuel efficiency for a car. Here's the code:</p>

<pre><code>class Car:
    def __init__(self, fuelEfficiency, fuelLevel):
        self.fuelEfficiency = fuelEfficiency
        self.fuelLevel = 0

    def drive(self, miles):
        gasUsed = self.fuelEfficiency * miles

        self.fuelLevel -= gasUsed

        self.fuelLevel = max(self.fuelLevel, 0)

    def get_gas_level(self):
        return self.fuelLevel

    def add_gas(self, gallons):
        self.fuelLevel += gallons

    def __str__(self):
        return ('$.2f gallons remaining.' % (self.fuelLevel))

def main():
    print("Fuel Estimator")

    fuelEfficiency = float(input('MPG: '))
    fuelLevel = float(input('Fuel: '))
    miles = float(input('Distance: '))
    gallonsRemaining = Car(fuelLevel)

    while True:
        x = input("Would you like to enter another (y/n): ")

        if x == "y":
            main()
            continue
        elif x == "n":
            break
        else:
            print("Would you like to enter another (y/n): ")

if __name__ == "__main__":
    main()
</code></pre>

<p>Here's the traceback from the error:</p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\John\Desktop\prog4.py", line 5, in &lt;module&gt;
    class Car:
  File "C:\Users\John\Desktop\prog4.py", line 47, in Car
    main()
  File "C:\Users\John\Desktop\prog4.py", line 33, in main
    gallonsRemaining = Car(fuelLevel)
NameError: name 'Car' is not defined
</code></pre>

<p>I'm still receiving a NameError stating that Car (the class) is not defined. What did I do wrong?</p>