find=(input("Are you trying to find how much the plant will grow or if you will need to
replace the filter?"))
if find=="how much the plant will grow":
p=float(input("how big is the plant now (in inches)"))
u=float(input("in how many days do you want to know how big the plant will get?"))
t=float(u*0.00821917808)
h=float(t p)
if h < 16:
print(t, "days")
elif print("The plant has reached maturity and will not grow anymore"):
if find=="replace the filter":
u=float(input("when was the last time you replaced the filter (in days)?"))
j=float(u/365)
if j < 5:
print("no need to replace the filter yet")
elif print("you need to replace the filter, luckily it is under waranty and you can get a new
one for free")
Heres the error:
Traceback (most recent call last):
File "<string>", line 11
if find=="replace the filter":
^
IndentationError: expected an indented block
CodePudding user response:
Near the middle of your code sample, you have elif print("The plant has reached maturity and will not grow anymore"): but nothing afterwards.
Python is expecting an indented chunk of code below that statement, but all it gets is another if statement a few lines later, which is where is the error is.
Edit: I just realized that you probably didn't even mean to use an elif-statement there in the first place. Did you mean to do else: print("The plant has reached maturity and will not grow anymore")?
CodePudding user response:
You have a couple indentation errors, best practice is to use 4*spaces when going inside a condition or loop. Also I think you are using elif when else is needed you might want to take a look on the differences between them
Here your code with a couple changes I made:
find=(input("Are you trying to find how much the plant will grow or if you will need to replace the filter?"))
if find=="how much the plant will grow":
p=float(input("how big is the plant now (in inches)"))
u=float(input("in how many days do you want to know how big the plant will get?"))
t=float(u*0.00821917808)
h=float(t p)
if h < 16:
print(t, "days")
else:
print("The plant has reached maturity and will not grow anymore")
elif find=="replace the filter":
u=float(input("when was the last time you replaced the filter (in days)?"))
j=float(u/365)
if j < 5:
print("no need to replace the filter yet")
else:
print("you need to replace the filter, luckily it is under waranty and you can get a new one for free")
