Someone help with this python if and else statements issue on Python Idle

Joined
Jan 14, 2021
Messages
2
Reaction score
0
It always says syntax error and highlight the l in "Left". this is the code:

Code:
cn=int(input("Please enter your credit card number to pay $8"))
print ("scanning...")
ba=int
ba==343
left=int
left== 343-8
print ("$343 in bank account")
a1=str (input("do you want to purchase the surprise bonus?"))
if (a1=="yes" or "Yes"):
    (print ("okay, thank you. Purchase completed successfully. remaining: $"left))
else:
    print ("Purchase cancelled")

a2=input("You can safely exit")
 
Joined
Feb 8, 2021
Messages
8
Reaction score
2
There are several things wrong with that code. Compare it with this working version.

Python:
cn = int (input ("Please enter your credit card number to pay $8"))
print ("scanning...")
ba =343
left = 343 - 8
print (f"${left} in bank account")
a1=str (input("do you want to purchase the surprise bonus?"))
if a1 == "yes" or a1 == "Yes" :
    print ("okay, thank you. Purchase completed successfully.")
    print (f"remaining: ${left}")
else:
    print ("Purchase cancelled")

a2=input("You can safely exit")
 
Joined
Feb 18, 2021
Messages
6
Reaction score
0
Looking for someone who can help with frontend, backend, and mobile development technologies.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top