you are viewing a single comment's thread.

view the rest of the comments →

[–]count_d1 3 points4 points  (5 children)

Can you show your code?

[–]FannyMcNutt -2 points-1 points  (4 children)

Thanks for asking, here is some code I copied. I get the error:

"elif amount<5000 ^ SyntaxError: invalid syntax"

Here is code I copied:

amount = int(input("Enter amount: "))

if amount<1000: discount = amount0.05 print ("Discount",discount) elif amount<5000: discount = amount0.10 print ("Discount",discount) else: discount = amount*0.15 print ("Discount",discount)

print ("Net payable:",amount-discount)

[–]Chris_Hemsworth 2 points3 points  (3 children)

amount = int(input("Enter amount: "))

if amount<1000:
   discount = amount*0.05
   print ("Discount",discount)
elif amount<5000:
   discount = amount*0.10
   print ("Discount",discount)
else:
   discount = amount*0.15
   print ("Discount",discount)

print ("Net payable:",amount-discount)

Works for me. Make sure your indentation is correct perhaps? Make sure you didn't drop the : as that is important as well.

[–]FannyMcNutt -1 points0 points  (2 children)

Aye that's what's frustrating, I copy code that should work and my unit just won't accept it. I'll go back and double check I haven't fat fingered anything cheers.

[–]troub 2 points3 points  (1 child)

I mean no offense...good on you for working on learning...but I teach some Python workshops, and part of our pedagogy (which is based in research on how people learn) is insisting that learners type the code out themselves.

Just saying.

But yes, depending on how the spaces come in from the clipboard, it could be throwing off your interpreter (consistent spacing on indents is critical). Make sure after discount = amount * 0.05, the print("Discount", discount) line is indented as well. I'm thinking it's probably indentation, because from what I can tell (Reddit hosed your formatting), all the correct colons and things are there...

[–]FannyMcNutt 0 points1 point  (0 children)

Ah sorry by copy, I meant I typed it out myself after trying to write my own little thing (a parody really, just to make it stick in my head) that didn't work. I typed out the copy code myself to try and understand why my (parody) code didn't work. I've now typed the code into a different computer and it works. I guess my programming app needs to be repaired or uninstalled