0
import time
def pini():
    pin1 = int(input("enter your pin please: ")
    if pin1 == pin:
            print("pin correct")
            print("paying: £",amount)
            print("opening connection...")
            time.sleep(0.4)
            print("contacting bank...")
            time.sleep(1.0)
            print("contacting bank...")
            time.sleep(0.5)
            print("contacting bank...")
            time.sleep(0.2)
            print("contacting bank...")
            time.sleep(0.2)
            print("transaction successful")
    elif:
            print("wrong pin, try again")
            pini()

print("Welcome to the bank")
print("\n")
pin = int(input("what is your pin: ")

pay = ""
while pay == "":
    pay = input("press 'n' to make a payement: ").lower()
    if pay == "n":
            amount = int(input("please enter amount to pay: ")
            print("please insert your card to pay" , "£",amount)
            print("\n")
            pini()

That is my code.

When running, I get an 'invalid syntax' error, I'm using Python/IDLE 3.4.2. This is just a small program for a school project which I'm having an error with.

I think it may be indenting that is the issue but otherwise I'm not sure, any help appreciated :)

SparkAndShine
  • 17,001
  • 22
  • 90
  • 134
nick
  • 31
  • 4

2 Answers2

2

I put some comments in your code, as shown below.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import time
def pini():
    pin1 = int(input("enter your pin please: "))    # miss a right bracket ')'
    if pin1 == pin:                                 # Be attention to your code indentation
        print("pin correct")
        print("paying: £",amount)
        print("opening connection...")
        time.sleep(0.4)
        print("contacting bank...")
        time.sleep(1.0)
        print("contacting bank...")
        time.sleep(0.5)
        print("contacting bank...")
        time.sleep(0.2)
        print("contacting bank...")
        time.sleep(0.2)
        print("transaction successful")
    else:       # it should be `else` instead of `elif`
        print("wrong pin, try again")
        pini()

print("Welcome to the bank")
print("\n")
pin = int(input("what is your pin: "))   # Again, you miss the right bracket `)`

pay = ""

while pay == "":
    pay = input("press 'n' to make a payement: ").lower()
    if pay == "n":
        amount = int(input("please enter amount to pay: ")) # Same problem `)`
        print("please insert your card to pay" , "£",amount)
        print("\n")
        pini()
SparkAndShine
  • 17,001
  • 22
  • 90
  • 134
1

To continue what Jim said, your code should read

def pini():
    pin1 = int(input("enter your pin please: "))

You might want to think about using an IDE - https://en.wikipedia.org/wiki/Integrated_development_environment - as these can highlight simple errors such as this (e.g. Eclipse is my choice). Asking which is the best one - What IDE to use for Python?

Community
  • 1
  • 1
A. N. Other
  • 392
  • 4
  • 14