I am creating a little program that creates Ice Cream. It's really simple but I cannot see what is messing up the process. I assume it is my lack of experience with functions and calling on them.
Basically, it creates an ice cream randomly...but I would like to call a function within a function and it is not appearing. It should create a random spoonful amount after creating the flavor and scoops of ice cream with the function of create_icecream.
Basically, it Produces a "Yes" or "No" and prints that.
If it randomly selects "Yes", it proceeds with making the ice cream and its variables.
However, I am not sure the order I want it to list it. So in the future, if I change the code, I would like to decide in the function appear_icecream, what it will call first...ie the function create_icecream() or consumption() first just when displaying it...I believe consumption() has to be defined after create_icecream() but still learning.
Here is what I have written so far:
import random
icecream_flavor = ["Chocolate","Vanilla","Strawberry"]
icecream_scoops = ["One","Two","Three","Four"]
icecream_made = ["yes","no"]
def create_icecream():
icecream_flavor_c = random.choice(icecream_flavor)
icecream_scoops_c = random.choice(icecream_scoops)
# Ice Cream Details: Printed
print("Scoops: ",icecream_scoops_c)
print("Flavor: ",icecream_flavor_c)
def consumption():
if icecream_scoops == "One":
icecream_spoonfuls = random.randint(0, 25)
print("Spoonfuls: ",icecream_spoonfuls)
elif icecream_scoops == "Two":
icecream_spoonfuls = random.randint(26, 50)
print("Spoonfuls: ",icecream_spoonfuls)
elif icecream_scoops == "Three":
icecream_spoonfuls = random.randint(51, 75)
print("Spoonfuls: ",icecream_spoonfuls)
elif icecream_scoops == "Four":
icecream_spoonfuls = random.randint(76, 100)
print("Spoonfuls: ",icecream_spoonfuls)
else:
return
def appear_icecream():
icecream_appear = random.choice(icecream_made)
# print(icecream_appear)
if str(icecream_appear) == "yes":
print("Yes")
create_icecream()
consumption()
elif str(icecream_appear) == "no":
print("No Ice Cream")
else:
print("BUG!")
print("Ice Cream No.1")
appear_icecream()
print("Ice Cream No.2")
appear_icecream()
An Example of the Run:
Ice Cream No. 1
Yes
Scoops: One
Flavor: Strawberry
Ice Cream No. 2
No Ice Cream
Obviously, the number of spoonfuls variable is not showing up.