FruitBasket Python
FruitBasket Python
def main(args):
print("Catch and eat any of these fruits : ('apple', 'orange','mango',
'guava')")
print("How many of these fruits would you like to catch? ", end = '')
fruits = sc.nextInt()
i = None
select = None
print("Choose a fruit to catch. Press A, O, M or G.")
i = 1
while i <= fruits:
print("Fruit " + i + " of " + fruits + " : ", end = '')
select = input.next().charAt(0)
if select == 'a':
st.push("'apple' ")
elif select == 'o':
st.push("'orange' ")
elif select == 'm':
st.push("'mango' ")
elif select == 'g':
st.push("'guava' ")
else:
print("You input wrong letter please pick only A, O, M or G.")
i += 1
print("Your basket now has: " + st)
while True:
print("Press E to eat a fruit: ", end = '')
eat = sc.next().charAt(0)
if eat == 'e' or eat == 'E':
st.pop()
print("Fruit(s) in the basket = " + st)
if st.empty():
print("No more fruits.")
break
else:
print("You input wrong letter please pick only E.")