파이썬으로 약간의 응용 프로그램을 만들고 있지만 다음에 무엇을해야할지 전혀 모릅니다.이 문제를 해결하는 방법 (파이썬)
#!/usr/bin/env python
print("Welcome to the store!")
price_list = [['apple', 'orange', 'grapefruit', 'bomb', 'gun'], [3, 2, 5, 15, 10]]
inventory = []
print("You can buy the following things")
print(price_list[0][0])
print(price_list[1][0], 'dollars')
print(price_list[0][1])
print(price_list[1][1], 'dollars')
print(price_list[0][2])
print(price_list[1][2], 'dollars')
print(price_list[0][3])
print(price_list[1][3], 'dollars')
print(price_list[0][4])
print(price_list[1][4], 'dollars')
budget = 20
buy = input("What would you like to buy? Type in one of the previous options to buy something You only have 20 dollars to spend though! ")
print("You bought", buy)
if budget >= 0:
if buy == 'apple':
print("It cost 3 dollars")
budget -= 3
inventory.append('apple')
print("Your inventory is below")
print(inventory)
if buy == 'orange':
print("It cost 2 dollars")
budget -= 2
inventory.append('orange')
print("Your inventory is below")
print(inventory)
if buy == 'grapefruit':
print("It cost 5 dollars")
budget -= 5
inventory.append('grapefruit')
print("Your inventory is below")
print(inventory)
if buy == 'bomb':
print("It cost 15 dollars")
budget -= 15
inventory.append('bomb')
print("Your inventory is below")
print(inventory)
if buy == 'gun':
print("It cost 10 dollars")
budget -= 10
inventory.append('gun')
print("Your inventory is below")
print(inventory)
내가 내 예산을 reahed 때까지 그렇게 난 후, 한 가지를 추가 할 다른 일을 추가 할 수 있습니다 만들고 싶어,하지만 난 잠시 문을 사용하는 경우, 그냥 내가 사는 일을 추가 유지 ! 도와주세요!
이 숙제입니까? 미안하지만 지금 당장은 숙제의 냄새가 난다. ... – blahman
아, 숙제인지 알아낼 때까지 내 대답을 지우겠다. 조금 너무 쉬웠다. –
@ mathematical.coffee - upvote ... 당신은 그에게 힌트를 제공해야합니다! :) 아마도 나는 숙제로 다시 태그를 붙였습니다. 그렇지 않더라도, 그것은 그 구경입니다. – prelic