Question: Create a stacktrace for this code for an upvote please quickly assignment is due soon starter code: #define list of flowers myFlowers = ['daffodil', 'lavendar',

Create a stacktrace for this code for an upvote please quickly assignment is due soon

starter code:

#define list of flowers myFlowers = ['daffodil', 'lavendar', 'lily', 'daisy', 'rose', 'hydrangea', 'dahlia', 'sunflower'] #Function that determines if given flower is one of the top three favorites def favoriteFlower(): #check if given flower is in the top three, return True (boolean) if is return print("Is lily one of my favorite flowers? ", favoriteFlower("lily",myFlowers)) print("Is orchids one of my favorite flowers? ", favoriteFlower("orchids",myFlowers)) print("Is rose one of my favorite flowers? ", favoriteFlower("rose",myFlowers))

code that needs stack trace:

# List of Flowers

myFlowers = ['daffodil', 'lavendar', 'lily', 'daisy', 'rose', 'hydrangea', 'dahlia', 'sunflower']

# function that determine that if the given flower is one of the top three favorites

def favoriteFlower(flower, my_flower): # function Definition

topThree = my_flower[0:3] # slicing first 3 elements of given list and storing in another list 'topThree'

# [0:3] means start slicing from index 0 and stop at index 3(excluding index 3) which contains index 0,1,2

if flower in topThree: # checking if given flower is available in list 'topThree'

return True # if available return True

else: # if not available

return False # return False

print("Is lily one fo my favorite flowers? ", favoriteFlower("lily", myFlowers))

print("Is orchids one fo my favorite flowers? ", favoriteFlower("orchids", myFlowers))

print("Is rose one fo my favorite flowers? ", favoriteFlower("rose", myFlowers))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!