ATM 코드를 작성 중입니다. 최선의 노력에도 불구하고 수정할 수없는 코드가 있습니다. 다음은 오류 메시지입니다 :파이썬 - 밑이 10 인 int()에 대한 리터럴이 잘못되었습니다.
line 35, in Withdraw
back2_menu = int(input("Do You Wish To Have Another Transation? "))
ValueError: invalid literal for int() with base 10: 'Y'
그리고 여기이 나의 프로그램이 원활하게 실행 난 그냥 해결하는 방법 궁금 코드
def Withdraw2(self):
amount = int(input("How Much Do You Wish To Withdraw: \n £"))
if int(amount) <= self.balance:
self.balance = self.balance - amount
print("Withdrawl Accepted. \nYour New Balance Is: £" + str(self.balance))
else:
print("Withdrawl Denied. \n You Have £" + str(self.balance) + "Within Your Account")
again = int(input("Do You Wish To Enter Another Amount"))
if again in ("Y", "y", "Ye", "ye", "Yes", "yes"):
print(atm.Withdraw2())
else:
backmenu = str(input("Do You Wish To Have Another Transation? "))
if backmenu in ("Y", "y", "Ye", "ye", "Yes", "yes"):
print(atm.Menu())
else:
print(atm.End())
의 번잡 한 작품이다. 감사합니다.
int ("Y")'는 무엇입니까? –
문자열을 int로 변환하려고합니다. 'int' 캐스트를 제거하면 괜찮을 것입니다. 'back2_menu = input ("당신은 다른 변환을 원합니까?")'. 이 코드를 코드에 적용하면이 오류가 몇 군데 표시됩니다. – asdf
@BadKarma, 많은 감사합니다. 이 코드는 완벽하게 작동합니다. –