Question: In Python, Check this code: # # Here we import the random module. import random #_______________________________ # Here we define the two lists needed using

In Python,

Check this code:

#

# Here we import the random module.

import random #_______________________________

# Here we define the two lists needed using the split() method.

suits = "Clubs Diamonds Hearts Spades".split()

values = "Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King".split()

#______________________________ # This function generates a random card

def randomCard():

return values[random.randint(0,12)] + " of " + suits[random.randint(0,3)]

#_______________________________

# 'hand' gets 5 random cards. and 'card' gets a random card.

hand = []

for i in range(5):

hand.append(randomCard())

card=randomCard()

#_______________________________

# The function GoFishFor() checks to see:

#1 * If 'card' is in 'hand': we remove it from 'hand' and return both in a list.

# 2* If 'card' is not in 'hand': we return the string 'Go Fish'.

def GoFishFor(card,hand): for c in hand:

if card == c:

hand.remove(card)

return [card, hand]

return 'Go Fish'

#________________________________________________________________________________

Write a functions 'GoFishIn(card, hand)' to replace the GoFishFor(card, hand) function.

The only difference between the two functions you're being asked to 'remove the for loop' and use the 'in

operator'

Only write the GoFishIn() function.

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!