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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started