Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f6413c6

Browse files
code correction - working
1 parent c53236e commit f6413c6

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

‎FruitStore/main.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,13 @@ def getAvilableStock():
1313

1414
def getUserInput(fromWhichMenu):
1515

16+
inputMessage = ''
1617
if fromWhichMenu == "fromMainMenu":
17-
try:
18-
choice = input("Please enter your choice : ").strip()
19-
except ValueError:
20-
print("That's not an int!")
21-
return choice
18+
inputMessage = "Please enter your choice : "
2219
elif fromWhichMenu == "fruitMenu":
23-
try:
24-
choice = input("Please enter your choice : ").strip()
25-
except ValueError:
26-
print("That's not an int!")
27-
return choice
20+
inputMessage = "Please enter your choice : "
2821
elif fromWhichMenu == "numbers":
29-
try:
30-
choice = input("how many you need? ").strip()
31-
except ValueError:
32-
print("That's not an int!")
33-
34-
return choice
22+
inputMessage = "how many you need? "
3523
elif fromWhichMenu == "addMoreItems":
3624
try:
3725
choice = input("Do you want to add more items to your cart? Y or N ").strip()
@@ -50,6 +38,13 @@ def getUserInput(fromWhichMenu):
5038
return False
5139
except ValueError:
5240
print("That's not a valid password!")
41+
42+
try:
43+
choice = input(inputMessage).strip()
44+
except ValueError:
45+
print("That's not an int!")
46+
47+
return choice
5348

5449

5550

@@ -127,17 +122,16 @@ def buyFruit(fruitId):
127122
showAvailableFruits()
128123
choice = getUserInput("fruitMenu")
129124
buyFruit(choice)
130-
# getUserInput("addMoreItems")
131125
else:
132126
displayFruitMenu()
133127
elif userChoice == '3':
134128
cartItems = cartInstance.showCart()
135129
print("Currently you have below items in your cart, ")
136130
for itemName, itemCount in cartItems.items():
137-
print(itemName + "-" + str(itemCount))
131+
print(itemName + "-" + str(itemCount))
132+
time.sleep(7)
138133
elif userChoice == '4':
139134
checkOutCart()
140-
141135
print("Enjoy Shopping at Ram's Fruit Store!\n")
142136
break
143137
elif userChoice == '5':

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /