Need help with running the code, i can run the block individually but altogether i get errors when i execute ...it says syntax error after using elif followed by if

age=int(input(“entre age:\n”))
if age<8:
print(“you can avail 10% discount”)
prescription=input(“enter prescription no. :\n”)
bill=float(input(“entre amt”))
discount_amt=(bill/100)*10
print(“discounted amt is:\n”,discount_amt)
total=bill-discount_amt
print(“amt to be paid is:\n”,total)
elif age>60:
print(“you can avail 20% discount”)
prescription=input(“enter prescription no. :\n”)
bill=float(input(“enter amt”))
discount_amt=(bil/100)*20
print(“discounted amt is:\n”,discount_amt)
total=bil-discount_amt
print(“amt to be paid is:\n”,total)
else if age in range(8,60):
print(“no discount for your age”)

I’ve edited the original post, but it looks like the formatting wasn’t there to begin with as it’s still a solid block of Python…

@beta9649826136, you can learn how to format your code by reading this topic.

2 Likes

else if is not a valid construct in Python.

You start a conditional branch with if, elif is the portmanteau of “else if” which declares another condition, and else is the final catch-all if no previous conditions match:

if condition1:
    do something
elif condition2:
    do something else
elif condition3:
    do another thing
else:
    nothing matches, do this

Whether there are any other issues remains to be seen, as we have no idea how you indented the program…

2 Likes

Indentation matters in Python. This might be helpful too:

https://www.programiz.com/python-programming/statement-indentation-comments

1 Like