擅长:python、mysql、java
<p>你很接近。您可以按如下方式扩展您的函数。你知道吗</p>
<pre><code>def get_card_suit_string_from_number(n):
''' Returns the name of the suit that corresponds to the value n, or None if n is an invalid number. '''
n = random_suit_number()
if n == 0:
return 'Spades'
elif n == 1:
return 'Hearts'
elif n == 2:
return 'Clubs'
elif n == 3:
return 'Diamonds'
else:
return None
</code></pre>