Disclosure: I'm a Python (& coding) infant. I just started CS, I'm doing my best but I'm struggling. This is a homework problem. I'm assigning a card suit based on a randomly generated integer (from 0 to 3), s.t. 0 = Spades, 1 = Hearts, 2 = Clubs, and 3 = Diamonds.
Here is what I'm given:
def random_suit_number():
''' Returns a random integer N such that 0 <= N < 4. '''
pass
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. '''
pass
And here is the (sad, sad) point I'm at:
def random_suit_number():
''' Returns a random integer N such that 0 <= N < 4. '''
return random.randint(0, 3)
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:
get_card_suit_string_from_number(n) = 'Spades'
Can someone please logic me through this? It's obviously not finished, Repl's telling me "get_card_suit_string_from_number(n) = 'Spades'" is invalid syntax; it's taken me hours to get to this point so I'm really dragging my teeth on cement right now.
Aucun commentaire:
Enregistrer un commentaire