Python Forum
Syntax error for code that seems correct
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax error for code that seems correct
#1
I'm pretty new to programming and Python so there may be other issues with my code here. The error is in line 8 of the code.

I keep getting a syntax error on the = and if I delete that I get it on the <. I've crossed referenced with my Python book but it looks good. Any ideas as to what the issue is?


#Display message
print("Shipping Calculator")

#Get data
choice = "y"
while choice.lower() == "y":
    cost = float(input("Cost of items ordered: "))
    if cost  >= 0 and <= 30.00:
        shipping = float(5.95)
        print("Shipping cost      " + str(shipping))
    elif cost <= 49.99:
        shipping = float(7.95)
        print("Shipping cost:     " + str(shipping))
    elif cost <= 74.99:
        shipping = float(9.95)
        print("Shipping cost:     " + str(shipping))
    elif cost > 74.99:
        shipping = float(0)
        print("Shipping cost:     " + str(shipping))
    elif cost < 0:
        print("Error! Please enter a positive number and try again. ")
    total = cost + shipping
    print("Total Cost:        " + str(total))
    #Get user choice
    choice = input("Would you like another calculation? y/n: ")

#Display Bye
print("Bye!")
Reply


Messages In This Thread
Syntax error for code that seems correct - by mcnhscc39 - Nov-14-2018, 09:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Please check whether the code about the for loop question is correct. (SyntaxError) lilliancsk01 10 2,632 Nov-08-2022, 01:25 PM
Last Post: deanhystad
Shocked School project -- need help with it it says syntax error XPGKNIGHT 6 3,347 Aug-11-2022, 08:43 PM
Last Post: deanhystad
  Is that code correct? Sameh 7 3,012 May-22-2021, 04:29 PM
Last Post: Sameh
  I'm getting a syntax error very early on in my code and I can't quite figure it out. liloliveoil 1 2,022 Oct-30-2020, 05:03 AM
Last Post: deanhystad
  Unspecified syntax error hhydration 1 2,027 Oct-25-2020, 10:45 AM
Last Post: ibreeden
  Annuity function for school - syntax error peterp 2 1,995 Oct-12-2020, 10:34 PM
Last Post: jefsummers
  Invalid syntax error, where? tucktuck9 2 3,439 May-03-2020, 09:40 AM
Last Post: pyzyx3qwerty
  Raise an exception for syntax error sbabu 8 3,235 Feb-10-2020, 01:57 AM
Last Post: sbabu
  syntax error: can't assign to operator liam 3 4,075 Jan-25-2020, 03:40 PM
Last Post: jefsummers
  Self taught , (creating a quiz) syntax error on my array DarkAlchemyXEX 9 4,332 Jan-10-2020, 02:30 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020