如何在python 2.7中为ATM制作Pin pritection事物

时间:2016-03-13 15:53:58

标签: python python-2.7

好的,所以我完成了大部分工作,但我的密码并没有正常工作。你可以输入一个代码,但我希望它是你只能输入例如1234进入,因为到目前为止你可以但任何数字并得到它,我尝试使用else语句,但我不能让它工作,任何帮助?也有人知道我怎么能把这些东西写到一个文件,例如,你写你的名字,如乔,它找到你的余额等也许我也可以用引脚做这个?不确定需要一些帮助,谢谢

balance = float(0)

userInput =无

pin = int(输入('请输入卡上的4位数字针脚:')

如果pin ==(1234):         打印('正确的针脚!')

print"您好,欢迎来到ATM"

而userInput!=" 4":

userInput = raw_input("\n what would you like to do?\n\n     (1)Check balance\n     (2)Insert funds\n" +

"     (3)Withdraw funds\n     (4)Exit the ATM\n" )




if userInput == "1":

    print "your balance is", "£" , balance

elif userInput == "2":

    funds = float(raw_input("Enter how much money you want to add"))

    balance = balance + funds

elif userInput == "3":

    withdraw = float(raw_input("Enter how much money you want to withdraw..."))

    balance = balance - withdraw

elif userInput == "4":

    print "Thanks for using the ATM!"

0 个答案:

没有答案